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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I Write Data to a *.xlxsx File Without Screwing Up the Excel File Formatting?

Solved!
Go to solution

I'd like to programatically add LabVIEW-generated data to a nicely-formatted *.xlsx file, one with all the right borders and column widths, etc.  But every time I try to add the LabVIEW data, the xlsx file formatting gets all screwed up and the file gets corrupted.  Is there a way around this?


Thanks!

 

- FB

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 1 of 7
(2,983 Views)

How are you modifying it? Are you using the XML parser? However you are doing it you have to make sure you are paying close attention to the spec in the MSDN. I have never used it but the report generation toolkit might help a lot.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 7
(2,981 Views)
Solution
Accepted by topic author diarmaede

It will probably be easier to use ActiveX to control Excel and modify the file that way if you have that option, instead of writing the XML directly.

0 Kudos
Message 3 of 7
(2,974 Views)

Absolutely! But even that is a pain. I don't know for sure but I would imagine that the report generation toolkit uses ActiveX under the hood.

=====================
LabVIEW 2012


0 Kudos
Message 4 of 7
(2,969 Views)

@Steve Chandler wrote:

Absolutely! But even that is a pain. I don't know for sure but I would imagine that the report generation toolkit uses ActiveX under the hood.


Yes, the Report Generation Toolkit uses ActiveX automation to build Excel and Word reports.

0 Kudos
Message 5 of 7
(2,961 Views)

FB,

 

I was able to find the following link on the NI website.  I think it addresses the issue you are describing using the Excel ActiveX interface.

 

AutoFit Columns and Rows in Excel Using LabVIEW: http://digital.ni.com/public.nsf/allkb/8697100BBFA68902862571D4006D893B?OpenDocument

 

 

Regards,

Isaac S.

Regards,
Isaac S.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 7
(2,940 Views)

I'm slogging my way up the ActiveX learning curve.  It's challenging, but fun.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 7 of 7
(2,925 Views)