From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-21-2021 11:14 AM
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.
Solved! Go to Solution.
04-21-2021 11:33 AM - edited 04-21-2021 11:38 AM
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:
04-21-2021 12:18 PM
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?
04-21-2021 12:37 PM - edited 04-21-2021 12:50 PM
@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.
04-21-2021 01:50 PM - edited 04-21-2021 01:51 PM
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!)
04-21-2021 02:19 PM
Thank you for all the help!
Yes, RGT functions did the trick.
04-21-2021 02:22 PM
04-21-2021 03:32 PM
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.