Hi,
I am trying to extract data from an excel file and the following script only works on IE. Is there a generic process available that will work on IE,chrome,FireFox and mozilla?
Here is the code I currently have:
<html>
<head>
<title>
Style Get data from excel sheet
</title>
<script language="javascript" >
function GetData(cell,row){
var excel = new ActiveXObject("Excel.Application");
var excel_file = excel.Workbooks.Open("C:\\Temp\\names.xlsx");
var excel_sheet = excel.Worksheets("Sheet1");
var data = excel_sheet.Cells(cell,row).Value;
document.getElementById('div1').innerText =data;*/
window.open('C:\\Temp\\names.xlsx', 'excel');.
}
</script>
</head>
<body>
<p> </p>
<div style="background: #009955; width:'100%';" align="center">
<font color="#000080" size="12pt">
<b>Get data from excel sheets</b>
</font>
</div>
<center>
<p> </p>
<div id="div1" style="background: #DFDFFF; width:'100%';" align="center">
Click buttons to fetch data from C:\\Temp\\names.xlsx
</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>
</body>
</html>
Hello,
There are a couple of items here:
- Excel spreadsheet file (XLSX)
- File in C:\Temp
- ActiveXObject
The short answer is that ActiveX objects is only supported by Internet Explorer (also it requires Excel to be installed ("Excel.Application").
A possible approach, specially if you are going to do this from a Mobile device, would be to process the XLSX file on the server (either with Excel.Application or other libraries) and return a JSON file to the client with the data.
I hope this helps.
Meyrick Flanegan |
Developer - Managed Services |
Email: mflanegan@elcb.co.za |
|
ELCB Information Services (Pty) Ltd |
Customer Service Email elcb@elcb.co.za · www.elcb.co.za |
E A S T L O N D O N Tel: +27(43) 704 0700 Fax: +27(43) 704 0701 |
J O H A N N E S B U R G Tel: +27(11) 879 6179 Fax: +27(11) 454 0384 |
P O R T E L I Z A B E T H Tel: +27(41) 373 0529 Fax: +27(86) 650 0135 |
Hello,
There are a couple of items here:
- Excel spreadsheet file (XLSX)
- File in C:\Temp
- ActiveXObject
The short answer is that ActiveX objects is only supported by Internet Explorer (also it requires Excel to be installed ("Excel.Application").
A possible approach, specially if you are going to do this from a Mobile device, would be to process the XLSX file on the server (either with Excel.Application or other libraries) and return a JSON file to the client with the data.
I hope this helps.
Flag this post as spam/abuse.
Hello Meyrick,
I see that this is a scenario where you want to upload an XLSX file to server.
For a Mobile device, something to keep in mind that iOS does not provide a file system that you can browse for files.
Also, each app runs in a sandbox.
Perhaps, you could do this on Android using a PhoneGap plugin.
Still, the workflow of an app on a Mobile device would not be the same as on a Desktop computer.
Could you provide more information on what is the use case that your are trying to solve?
How does the XLSX file get to the Mobile device?
Thanks.
Meyrick Flanegan |
Developer - Managed Services |
Email: mflanegan@elcb.co.za |
|
ELCB Information Services (Pty) Ltd |
Customer Service Email elcb@elcb.co.za · www.elcb.co.za |
E A S T L O N D O N Tel: +27(43) 704 0700 Fax: +27(43) 704 0701 |
J O H A N N E S B U R G Tel: +27(11) 879 6179 Fax: +27(11) 454 0384 |
P O R T E L I Z A B E T H Tel: +27(41) 373 0529 Fax: +27(86) 650 0135 |
Hello Meyrick,
I see that this is a scenario where you want to upload an XLSX file to server.
For a Mobile device, something to keep in mind that iOS does not provide a file system that you can browse for files.
Also, each app runs in a sandbox.
Perhaps, you could do this on Android using a PhoneGap plugin.
Still, the workflow of an app on a Mobile device would not be the same as on a Desktop computer.
Could you provide more information on what is the use case that your are trying to solve?
How does the XLSX file get to the Mobile device?
Thanks.
Flag this post as spam/abuse.
Hello Meyrick,
I am considering that your target platform is Android (but some of this can also apply to iOS).
Copy and paste seems simple enough. However, you would depend on the app that opens the XLSX file to provide the right format so that you can process the text unambiguously.
Also, the interaction does not seem use friendly. (User has to do copy on an app that works with XLSX files then switch to your app and paste the text into a text area field.)
Using an import wizard would depend on being able to access the file on the file system.
Files owned by an app are only accessible by the app. If the XLSX file is stored in External Storage then it is public and available to any app. (This could be a security issue.)
developer.android.com/.../files.html
I believe that the best approach to do what you intend to do is to use Intents.
developer.android.com/.../receive.html
developer.android.com/.../intents-filters.html
developer.android.com/.../intents-common.html
I tried to find a PhoneGap plugin that worked with Intents but I only found the WebIntent Android Plugin.
Other possible approaches here could be to have a service where you receive the XLSX file via email or have it shared via a DropBox.
Perhaps, others in the forum have tried to solve a similar use case and have some suggestions.
Best regards.