LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D array into excel

Hi!

 

I am new to labview (2014, student version) and right now I am facing a problem which I can't solve alone:

 

Basically, the vi I wrote opens a .txt-file with 2 colums of data and does some changes to these data (I attached a shortened version of the file to this post).
After the data is changed, I'd like it to be saved to a new excel file with the same name as the the original .txt-file.

 

(Actually, for now I'd be happy enough if I could just save it to an existing file.)

 

Does someone have an easy (!!!) solution? I read on multiple forums, but none of the solutions I found worked properly.
I got as far as to creating a .xls-file, but it only opened in excel after telling me that something was wrong with the file format....

 

Help would really be appreciated, thank you!!

Download All
Message 1 of 14
(5,810 Views)

CHECK THE ATTACHED VI THIS WILL HELP U I THINK...

Message 2 of 14
(5,787 Views)

Hi Kubi,

 

LabVIEW comes with a lot of example VIs, also explaining file handling issues. Did you examine them?

 

To write an "Excel file" (a file in a format proprietary to Microsoft Excel) you need to use ActiveX functions or the ReportGenerationToolkit (which also uses ActiveX under the hood).

When you write simple spreadsheet files (aka CSV files aka formatted text) you should NOT name them using a "xls" suffix…

How did you create those files?

 

the vi I wrote opens a .txt-file … After the data is changed, I'd like it to be saved to a new excel file with the same name as the the original .txt-file.

You need to close the text file first, then you can create a new file with the very same name/path using simple file functions…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 14
(5,785 Views)

Thank you, guys, for the quick responses!

 

@Rizwan00 I'm afraid I cant open your file because apparently it's a newer version than my labview software... Could you maybe post a screenshot?

 

 

@ didn't know about the example VI's (basically started with labview yesterday 😄 ), but I actually found an example which is pretty much doing what I want. It looks really complicated though, I hope I can adapt it so it works with my project... Btw, the example uses the ActiveX functions you mentioned 😉  Unfortunately I do not have the Report Generation Toolkit.

 

 

 

 

0 Kudos
Message 4 of 14
(5,767 Views)

u can convert my vi  into your version by using vi converter...check this link http://forums.ni.com/t5/Version-Conversion/bd-p/VersionConversion

0 Kudos
Message 5 of 14
(5,764 Views)

Excel vs. text file... sounds familiar. Is that some kind of homework?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 6 of 14
(5,750 Views)

@Rizwan00 I don't have the admin rights to install tools

 

@ No it's not a homework

 

 

So I tried to adapt my little program to the example file from labview. It's basically working: when I hit the Run-button, it creates a new excel file which imports my values. The problem is, the values are somehow changed, e.g. 324.456 (in the .txt-file) appears as 324456000 in Excel... However, in Labview this number is correctly displayed as 324,456000...

 

Do you know, what the problem might be? The thing is, I hardly understand the labview example file...

 

Thank you!

 

 

Download All
0 Kudos
Message 7 of 14
(5,733 Views)

Kubi,

 

It seems like to me that Excel is formatting your data. You can play around with excel properties and formatting to properly display it.

 

PS - I can't open your vi as I have 2012, so I can't take a look under the hood, this is conjecture from looking at your pictures.

CLD | CTD
Message 8 of 14
(5,721 Views)

You write the date to Excel as string. What type of data does the column/cell have? If it numeric, you run into a string/number conversion issue which is likely fed by localized decimal point (, instead of .).

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 9 of 14
(5,713 Views)

u need to give format when wrie to excel

0 Kudos
Message 10 of 14
(5,708 Views)