LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Table to XL issue

I am using a slightly modified version of the "Table to XL.vi" to assist with importing data from a text into Excel.  I have run into a problem when using this. 

 

The data is being read from the text file and imported fine, except for one problem.  There are 2 columns I have that have time and date data.  After importing, this data is just displayed as normal numbers.  I have tried right clicking in Excel to change the format of the cells, but this does not help.

 

Does anyone know what might be going on?  Any suggestions as to how to fix this?

 

Thanks in advance.

Using Labview 7.0 and 2010 SP1 with Windows XP and 7.
0 Kudos
Message 1 of 6
(2,957 Views)

What values are in these 2 columns in the text file? Are you doing any kind of parsing in LabVIEW? Keep in mind that Excel and LabVIEW have different starting dates (there have been numerous posts on this over the years).  Can you provide your data and your code?

0 Kudos
Message 2 of 6
(2,927 Views)
Ta-DaTime to XL.PNG
Message Edited by Jeff Bohrer on 06-26-2009 01:53 PM

"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 6
(2,924 Views)
Using Labview 7.0 and 2010 SP1 with Windows XP and 7.
0 Kudos
Message 4 of 6
(2,898 Views)

Your code leaves a lot to be desired. I'll get to that in a minute... Your fundamental problem is that you are reading the file as floating point. This means that LabVIEW tries to convert "1:48:25 PM" to a floating point number. All you get is 1 because that's all you can get. There is no "automatic detection that it's a date" mechanism. You have to read the file as a 2D array of strings. You are using LabVIEW 7, which means you have to create a modified version of the Write to Spreadsheet File VI to read in the data as strings. Open the Write to Spreadsheet File VI. It contains comments on how to do this.

 

As for the code...

  • It is not immediately obvious that you're supposed to have the files inside of folders and have the forlder names to be the same as the file, up to the last "_". You should at least provide some sort of comment on the front panel.
  • You should not be opening Excel each time in the loop. Once is enough. If you want to save the files as new worksheets in the workbook, then create a new worksheet in the loop. Otherwise, create a new workbook in the loop. 
  • Learn to use the Format Into String function. It saves you having to use multiple Concatenate Strings functions.
  • Your data file has no column headers and row headers. Why are you putting them in?
  • Your code lists all the directories in a starting path, and then creates a file it expects to be in there. What if there's no file? Your code will generate an error dialog. This may or may not be desired behavior.

Finally, for the BIG question: why are you even doing this? All you're doing is copying the data from the text files into an Excel workbook. Why? Just open the files directly with Excel.
0 Kudos
Message 5 of 6
(2,875 Views)

Thanks for reply once again.  The code is very rough, and parts of it have been quickly copied from another program I have.  This was far from polished or finished product.  I did not even know if this would even work.  I thought about this idea (opening files via LV into Excel) not that long ago, and was just trying to look into how it was done.  This is more than just importing 1 file, sometimes many text files.  I just included 1 here as an example.  I thought it would be easier and quicker to do this via Labview than to import by "hand" many, many text files.  Like I said, this was merely an idea I had.  I have no headers at the moment in the program, I just have not inputed the correct ones that I eventually want to use, hence why I just left the default ones there. 

 

I will look into your suggestions and work on them to imporve the program.  I know it needs much work, this was just a thought I had on a whim.  I know I am not the most "polished" programmer in the the world and still have much to learn about Labview.

 

Again, thanks for your comments.  The help here is always appreciated. 

Using Labview 7.0 and 2010 SP1 with Windows XP and 7.
0 Kudos
Message 6 of 6
(2,871 Views)