Retrieving data from excel

Posted by mflanegan on 13-Mar-2015 07:36

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>&nbsp;</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>&nbsp;</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>

All Replies

Posted by egarcia on 13-Mar-2015 08:21

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.

Posted by mflanegan on 13-Mar-2015 08:46

Hi Edsel.
 
How would I get the full file path to the file from the html control in my mobile app so I can store it as a memptr and send that to the server side?
 

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

Disclaimer


[collapse]
From: egarcia [mailto:bounce-egarcia@community.progress.com]
Sent: 13 March 2015 03:22 PM
To: TU.Mobile@community.progress.com
Subject: RE: [Technical Users - Mobile] Retrieving data from excel
 
Reply by egarcia

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.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by egarcia on 13-Mar-2015 09:09

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.

Posted by mflanegan on 16-Mar-2015 01:32

Hi Edsel
 
The scenario is as follows..
 
Users of our mobile application want the following….
 
They sit with excel spread sheets with data that needs to be loaded via the mobile app. They are requesting a copy paste facility where they can copy the data out of the spread sheet (on the tablet) and then paste it into a maintenance/capture screen and the mobile application should then process the records pasted…
 
E.g.: they have a spread sheet with customer orders…. 100 orders per customer. They want to be able to copy the 100 orders from the spread sheet and paste it into the customer orders maintenance screen on the mobile app and this screen should allow the processing of these orders all at once.
 
There are a few ways to go about doing this:
 
1)      Copy and paste
2)      Import wizard that accepts the file and extracts the information from the spread sheet and then displays the information in a grid before processing. The user will then click save to process.
 
I think option 2 here is the more accepted practise! However this seems to be a very big challenge.
 
Could you please comment on each of the following options on how to go about achieving this.
 
Thanks
Meyrick
 

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

Disclaimer


[collapse]
From: egarcia [mailto:bounce-egarcia@community.progress.com]
Sent: 13 March 2015 04:10 PM
To: TU.Mobile@community.progress.com
Subject: RE: [Technical Users - Mobile] Retrieving data from excel
 
Reply by egarcia

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.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by egarcia on 16-Mar-2015 09:22

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.

This thread is closed