04-09-2018 02:52 AM
Hello,
I need to read in labview an excel file in drive format, because my application ,when ready, will be runned on a PC without Microsoft Excel, the user will update the file from drive sheets ( it's a 2D string array) So I shouldn't go through ActiveX.
To proceed quickly, I have used temprary the function " array to spreadsheet string" and do " copy paste" of the file content every time i run Labview, but it's not a practical solution, as it's not efficient that the user will everytime copy paste a very long file to execute it !
Without using ActiveX, Is there a way / a function to browse the drive file to get as an output a 2D array of strings.
Thank you in advance for your help.
04-09-2018 03:08 AM
It's not very clear to me. What's a "drive format" or "drive sheets"? Do you mean binary format files?
You don't explain why the user should copy and paste the file. Why not reading the file directly?
04-09-2018 03:13 AM
04-09-2018 03:22 AM
To proceed quickly, I have used temprary the function " array to spreadsheet string" and do " copy paste" of the file content every time i run Labview, but it's not a practical solution, as it's not efficient that the user will everytime copy paste a very long file to execute it !
Why you use copy/paste? Just go to Excel, and "save as" the xls(x) file as a TAB delimited txt (or csv, etc.). Now LabVIEW can easily read the file. This is a quick step to do.
04-09-2018 03:39 AM
Hi,
I can't read the file directly because i don't have excel installed on my PC, that's why i shouldn't use ActiveX, in fact, the file is uploaded from drive (online).
So, in order to read the content of the file, i convert it to a string and then use " spreadsheet string to array", so i'm obliged everytime to copy paste the file content to have a string then a 2D string array so i can run my program. hOwever i want to read it directly
You will find attached what i have done
Thank you for your responses
04-09-2018 03:48 AM
I already told you that you need to save ("save as") the Excel file as a TAB or comma delimited text file, I imagine this should be done at the source PC (where you upload the file to the "drive").
It is very easy to read a simple text file using LabVIEW, you do not need to manually copy/paste the content as a string to a string control!
Here is how you can do it using comma delimited csv file: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LdGSAU
04-09-2018 03:50 AM
Definitely, you cannot read an Excel xlsx or xls file without Excel. It contains a lot of binary information about cell formats, formulas and so on.
Excel is absolutely needed to export such a file to a readable, (usually) tab delimited text file. Then, you can use Read spreadsheet file to load data into LabVIEW.
04-09-2018 04:20 AM
Look for an (open source) .NET library for open documents.
https://www.google.nl/search?q=office+document+.net+library+excel
Trick is to find one that has a build assembly (.dll), because you can't statically link against code...
04-09-2018 04:28 AM
Hi,
I see two options:
- Use a 3rd party tool (like XLR8) to read Excel files without needing to install Excel. You find XLR8 using VIPM.
- When you have to deal with XLSX files ("modern" Excel file formats) you can easily UNZIP them (infact they are just a ZIP container). Then you can parse all the Excel data content, which is XML coded…
04-09-2018 04:39 AM
@GerdW ha scritto:
Hi,
I see two options:
- Use a 3rd party tool (like XLR8) to read Excel files without needing to install Excel. You find XLR8 using VIPM.
- When you have to deal with XLSX files ("modern" Excel file formats) you can easily UNZIP them (infact they are just a ZIP container). Then you can parse all the Excel data content, which is XML coded…
Sure today you can find a software component for almost any task. However it has a cost. Parsing XML has a development cost too.
samehA should consider which is the best cost-to-benefit way to go, whether buying an Excel licence or something else.
The OP