LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot open a LabVIEW Excel generated file with extension (*.xlsx)

Solved!
Go to solution

Hi,

I have a VI that I'd used to create an Excel file with .xlsx extension.  I remember it used to work before. Now, when I create an .xlsx file, the file cannot be opened.  I got the Excel error message below.  If I change the extension to .xls and rerun the VI, then the file would open as normal. 

 

Capture.PNG

Capture.PNG

0 Kudos
Message 1 of 8
(254 Views)

Hi KCLL,

 


@KCLL wrote:

I have a VI that I'd used to create an Excel file with .xlsx extension.  I remember it used to work before. Now, when I create an .xlsx file, the file cannot be opened.  I got the Excel error message below.  If I change the extension to .xls and rerun the VI, then the file would open as normal. 


Most probably you create text files with a false file extension - and Excel claims that by refusing to open such "false" XLSX files!

When you write text/csv files then you should name them correctly…

 

Less string handling:

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 8
(245 Views)

Thanks for the quick response GerdW.

 

I thought you can use the 'Open/Create/Replace File' operator to create the file type of your choosing by giving it the proper extension. I have no issues with the *.XLS file it created.

 

What do you suggest I use to create a *.XLSX file?

0 Kudos
Message 3 of 8
(219 Views)
Solution
Accepted by KCLL

@KCLL wrote:

What do you suggest I use to create a *.XLSX file?


 

Either use the MS Office Report Generation Tool Kit that comes with some versions LabVIEW (can be added on if you don't have it) or a third party add-on like XLR8

 

Honestly I have found no reason to create actual XLS or XLSX files except for the convenience factor of having Excel launch and open the file when you double click on it.

 

I save all my data files in a plain (Tab delimited) text file with a txt extension. Since Excel is not associated as the default text file handler you have to jump through a few hoops to open it.

 

But if you open Excel, then open the text file from Excel. Excel launches the text importer and two mouse clicks later it's open in Excel. 

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 4 of 8
(202 Views)

Hi KCLL,

 


@KCLL wrote:

I thought you can use the 'Open/Create/Replace File' operator to create the file type of your choosing by giving it the proper extension.


Why do you think so? (Is anything like that written in the LabVIEW help?)

Using FileOpen you just create a file, using the path/filename you supply. The filename is not related to the data formatting of the file content!

 

As has been said: to create real XLSX files you should use functions from RGT (or the WriteMeasurementData ExpressVI)…

 


@KCLL wrote:

I have no issues with the *.XLS file it created.


This is not related to your capabilities or LabVIEW. This is a feature of Excel: it is much more error tolerant when importing ("deprecated" format) XLS files then when trying to open XLSX files! (XLSX files are in fact simple ZIP archives and Excel fails on unZIPping your XLSX files!)

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 5 of 8
(191 Views)

Thank you for all the help! 

 

Yes, RGT functions did the trick.

Capture.PNG

0 Kudos
Message 6 of 8
(185 Views)

Hi KCLL,

 

why do you need to convert a string to a path when you could use a path constant right from the beginning?

You also forgot to implement error handling…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 7 of 8
(183 Views)

 

Hey GerdW,

 

It's just my 'proof of concept' code.  In the actual code, I'll need to stitch together the SN,PN, and timestamp in a string before converting it to a path.

 

Yes, error handling will also be implemented in the actual code.

 

Thanks again.

0 Kudos
Message 8 of 8
(170 Views)