06-02-2016 03:43 AM
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!!
06-02-2016 04:22 AM
CHECK THE ATTACHED VI THIS WILL HELP U I THINK...
06-02-2016 04:24 AM - edited 06-02-2016 04:25 AM
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…
06-02-2016 05:29 AM
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?
@GerdW 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.
06-02-2016 05:35 AM
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
06-02-2016 05:49 AM
Excel vs. text file... sounds familiar. Is that some kind of homework?
Norbert
06-02-2016 06:36 AM
@Rizwan00 I don't have the admin rights to install tools
@Norbert_B 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!
06-02-2016 06:45 AM - edited 06-02-2016 06:46 AM
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.
06-02-2016 06:47 AM
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
06-02-2016 06:50 AM
u need to give format when wrie to excel