LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read an excel file without using ActiveX

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.

0 Kudos
Message 1 of 28
(4,962 Views)

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?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 28
(4,948 Views)
Hello,
 
I have read many discussions in the forum speaking about activeX tool. (For example with the report generation toolbox from ni) But, for me I can't use it for these reasons:
1.  Excel is not installed on the targed PC. (to get the ActiveX interface)
2. Even when i tried with ActiveX, I found always errors, because there exists different "Microsoft Excel x.x Object Library Version x.x" which have different methods and properties. If a costumer has an other version, it could be that it doesn't work.
Therefore I think it's better (if possible) to use Spreadsheet-files. They can be opened with all versions of Excel and used without activeX in LabVIEW..but does someone experiment with this before and give me some suggestions please !
 
0 Kudos
Message 3 of 28
(4,946 Views)

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.

Message 4 of 28
(4,940 Views)

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

0 Kudos
Message 5 of 28
(4,923 Views)

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

0 Kudos
Message 6 of 28
(4,917 Views)

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.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 28
(4,915 Views)

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...

0 Kudos
Message 8 of 28
(4,904 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 28
(4,902 Views)

@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

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 10 of 28
(4,889 Views)