LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Corrupting Files when Using Write to Spreadsheet File VI

Solved!
Go to solution

Hi everyone,

 

I am trying to write a 4x5 double array to an excel spreadsheet using the titular VI. However, when I try to do so and then open the resulting .xlsx file, Windows throws up an error message saying the file cannot be opened and may have been corrupted. This happens both when I specify an existing destination file and when I use the popup dialogue box to create one from scratch. The input array is very simple, and the VI is operating with the standard tab delimiter and %.d format. The array is assembled in a while loop, passed to subsequent loop iterations with a shift register, and then passed to the VI. No issues are present with the array itself, which looks like I expect it to. I would really appreciate some advice on this issue, as I can't figure out how something so simple could generate this error.

 

Thanks  

0 Kudos
Message 1 of 8
(4,126 Views)
Solution
Accepted by topic author AWS770

The problem is that you call it a .xlsx file, but it is missing some stuff that Excel expects. If you change the file to .txt, you should be able to open it up fine.

 

If you really do need a .xlsx file, you should use the Report Generation Toolkit.

0 Kudos
Message 2 of 8
(4,124 Views)

"Write to spreadsheet" has nothing to do with excel. If you want more detailed help, please attach a simplified version of your VI.

 

A file extension just defines which program is used if you double-click it in windows explorer. It does not define or verify a specific file structure.

 

(If you name it *.xls instead, excel might try to opend it, recognize it as delimited text file and load it, but this is not really recommended)

0 Kudos
Message 3 of 8
(4,119 Views)

@AWS770 wrote:

Hi everyone,

 

I am trying to write a 4x5 double array to an excel spreadsheet using the titular VI.


Unfortunately, I "no hablo" spanish


"Should be" isn't "Is" -Jay
Message 4 of 8
(4,080 Views)

As the others have said an XLSX file is not a text file. XLSX is actually a compressed XML file format.

 

Just make it a .txt and Excel will be able to open it, and is will then "import" it giving you the chance to select the delimiter.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 8
(4,065 Views)

By putting the word "Spreadsheet" in a VI that LabVIEW provides that writes a Comma-Separated-Values (.csv) type of text file, NI has confused many LabVIEW users into thinking this is writing an "Excel" file.  Well, Excel can open .csv files (and, in fact, prefers to "capture" this extension and misleadingly give it an "Excel-like" Icon).  However, Excel is designed to work with its own proprietary file types, .xls and .xlsx.  This confusion comes up repeatedly in the Forums ...

 

Bob Schor

Message 6 of 8
(3,985 Views)

@Bob_Schor wrote:

By putting the word "Spreadsheet" in a VI that LabVIEW provides that writes a Comma-Separated-Values (.csv) type of text file, NI has confused many LabVIEW users into thinking this is writing an "Excel" file.  Well, Excel can open .csv files (and, in fact, prefers to "capture" this extension and misleadingly give it an "Excel-like" Icon).  However, Excel is designed to work with its own proprietary file types, .xls and .xlsx.  This confusion comes up repeatedly in the Forums ...

 

Bob Schor


Similar to the "String to Decimal Number" and "Decimal Number to String" functions.  In these cases, as the case above, NI is technically correct, but confusing, because the colloquial uses of the terms are different.

 

When we think of spreadsheet files, we usually think of excel spreadsheets - but those aren't the only kinds of spreadsheet files.  A .csv file is also a spreadsheet file.  Hence the confusion.

 

When we think of "decimal" numbers, we tend to think of numbers with decimal points in them; however, technically it just means a base10 number.  An integer, in other words.  Hence the confusion generated when a new LabVIEW programmer uses the a node that I mentioned above and only gets integers and not fractional numbers.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 8
(3,976 Views)

@Bob_Schor wrote:

By putting the word "Spreadsheet" in a VI that LabVIEW provides that writes a Comma-Separated-Values (.csv) type of text file,


The default is tab delimited text.

 

To get a csv, you need to specify a different delimiter and potentially break things for international users (e.g. the ones that use comma a decimal delimiter).

0 Kudos
Message 8 of 8
(3,967 Views)