LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert a text file to Xslx

Hello,

Im new to Labview, though I have good knowledge in several coding languages. Im trying to figure a way to convert a txt file to an excel one. The text file is created by my original Labview program so Im trying to add a step where the text file gets converted to an excel. The text file is already separated with tabs (see attached files). When I open it using Microsoft Excel, It's all in order and good, but for several reasons, I need the program to create for me directly a .xslx file rather than a txt one even if it can be opened by excel correcly.
Attached to my message you'll find the text file I'm trying to convert and the VI I'm trying to use for that (You'll also find a screenshot of this VI in case of you need it)

I'm struggling with this for days and I'd really appreciate your help. 


PS: ActiveX or RGT solutions are too complicated for me, and i think my case is not complicated since the txt file is easy to work with.

Thank you all !

0 Kudos
Message 1 of 11
(3,691 Views)

Hi haamza,

 

ActiveX or RGT solutions are too complicated for me, and i think my case is not complicated since the txt file is easy to work with.

Well, the answer is: to create (real) Excel files you need to remotely command Excel to create them - using RGT or ActiveX!

 

When you really don't want to go this way you could buy any of those toolkits available in VIPM which help you to access Excel files. I can recommend XLR8 as an easy-to-use tool…

 

On your VI: just because of using "XLSX" as file extension doesn't make your spreadsheet file into a real Excel file! With WriteDelimitedSpreadsheet you create CSV (or TSV) files - please name them so!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(3,690 Views)

Thanks for your response. 

Well, It's not that I dont want to give RGT or ActiveX a try or that I'm lazy, I've been already trying some stuffs for days now and It just doesnt work, I just cant figure out how it does zork and Internet topics dont seem that helpful for me. If you can give me a hint for what should I look for I'd be really thankful for you !

0 Kudos
Message 3 of 11
(3,678 Views)

@haamza09 wrote:

Well, It's not that I dont want to give RGT or ActiveX a try or that I'm lazy, I've been already trying some stuffs for days now and It just doesnt work, I just cant figure out how it does zork and Internet topics dont seem that helpful for me. If you can give me a hint for what should I look for I'd be really thankful for you !


Well, you didn't try very hard.  LabVIEW comes with Examples.  The Forum comes with Examples.  The Web comes with Examples.

 

Open the Forum.  In the Search box at the top, type "Excel Example".  I recommend the one that is named "Revised "Generate Excel Report" Example" (I know the author).

 

Bob Schor

0 Kudos
Message 4 of 11
(3,670 Views)

Thanks you ! Im trying to find a way to figure out this using ActiveX. Even though, it still seems to me that Im taking the long way, Im surprised if in LV there's no way for reading a simple Txt file and saving it as a Excel.

0 Kudos
Message 5 of 11
(3,662 Views)

I know the author


Smiley LOL


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 6 of 11
(3,658 Views)

Hi haamza,

 

Im surprised if in LV there's no way for reading a simple Txt file and saving it as a Excel.

There is a simple way: you already know how to read the text file and there are the RGT functions to create Excel files. Once you understand how they work it becomes very easy…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 11
(3,650 Views)

There are several third-party toolkits like XLR8 out there that let you create xlsx files without ActiveX.

 

Regards, Jens

Kudos are welcome...
0 Kudos
Message 8 of 11
(3,646 Views)

@Bob_Schor wrote:

@haamza09

[...] I recommend the one that is named "Revised "Generate Excel Report" Example" (I know the author).

 Bob Schor


Smiley Very Happy

 

0 Kudos
Message 9 of 11
(3,633 Views)

Why do you need LabVIEW to do this? Excel has no problem opening text files.

 

  1. Launch Excel
  2. From the menu select File--->Open
  3. Browse to the directory your TXT file is in
  4. Set the file selection to Show All Files
  5. Select your text file
  6. Excel will automatically start the Text Import Wizard 
  7. Excel will ask you a couple questions about how your file is delimited
  8. Now you can save it as an Excel file (.xlsx)
========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 11
(3,619 Views)