/    Sign up×
Community /Pin to ProfileBookmark

Get text from excel using Javascript

Hallo all users from Webdeveloper.com,

I am new with Javascript and i am stock with this code:

[CODE]<script language=javascript>
function GetData(cell,row){
var excel = new ActiveXObject(“Excel.Application”);
var excel_file = excel.Workbooks.Open(data/data.xls);
var excel_sheet = excel.Worksheets(“Sheet1″);
var data = excel_sheet.Cells(cell,row).Value;
document.getElementById(‘Data’).innerText =data;
}

</script>

<center>

<div id=”Data”>Information</div>

<input type=”button” value=”cell(1),row(1)” onClick=”GetData(1,1);” />
<input type=”button” value=”cell(1),row(2)” onClick=”GetData(1,2);” />
<input type=”button” value=”cell(2),row(1)” onClick=”GetData(2,1);” />
<input type=”button” value=”cell(2),row(2)” onClick=”GetData(2,2);” />

</center>[/CODE]

Is there someone who knows this code, and know what I’m doing wrong.
The path would be wrong, or I miss the link to the excel doc.

Advance many thanks.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@grumpyOleManMar 10.2013 — What you have there is a typical ActiveX bit of JavaScript that works in IE only. Yes IE allowed that sort of behaviour to be allowed in their browser??

The way you have written the JavaScript (or copy and paste from elsewhere) requires a local copy of an excel file... THAT MEANS on the computer that opens the web page... not on any server or any computer in a foreign country.

Assuming you know all that and you are trying to get it to work on your computer ONLY and using Microsoft&#8217;s browser IE then it can be fixed.

What you are doing wrong is not giving the open command a valid path to your excel file.

*Open(data/data.xls)*

YOU need an absolute reference to your excel file which would look sumpin like this

"C:amitdata.xls" -- If you use your system drive as indicated BUT better to use a non system drive.

Remember you are using a Microsoft system so adhere to their lashes.
Copy linkTweet thisAlerts:
@K3v1nc0authorMar 10.2013 — Tanks Grumpyoleman,

Is there a different kind of way to achieve this with javascript. dit moet wel met een csv, xls bestand.

Advance many thanks.
Copy linkTweet thisAlerts:
@K3v1nc0authorMar 10.2013 — *dit moet wel met een csv, xls bestand.*

this should be a csv, xls file
Copy linkTweet thisAlerts:
@grumpyOleManMar 11.2013 — Based on your original request the answer is no.

If you are willing to start over then yes...

Using technologies that includes JavaScript you would have a html page that uses AJAX to send requests to a server that has PHP (or similar) installed and then the PHP will open/extract/return the requested data from the excel/csv/xml file for AJAX to display into your html page.......

Alternately you can send a request to a server with PHP installed to open/extract/return the requested data in a html file.....no JavaScript involved.

If you are trying to do this without the help of a server then the answer is again NO.
Copy linkTweet thisAlerts:
@K3v1nc0authorMar 11.2013 — Super,

I wil work on te php and Ajax thing, and comunicate with the server.

Thanks for the Quick Reply grumpyoleman.
×

Success!

Help @K3v1nc0 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...