07-25-2018 07:02 AM
Hi,
I've posted earlier today about my problem struggling to figure a way convert a txt file to a xlsx. so some of you convinced me to give ActiveX a try, here Iam, i found a bunch of VI on Internet and here Iam, I feel that Im getting closer to what Im looking for but still dont work.
Atached to my message you'll find the VI and the text file Im trying to convert. If any of you can spot the problem and help me. Id reaally appreciat it !!
Thanks
07-25-2018 07:21 AM
In your previous post, you suggested you could use ActiveX (based on a proprietary technology that even Microsoft, who originated it, has abandoned) and the RGT. I provided links to doing what you need using the RGT. Before discovering this useful Toolkit, I also tried, and gave up on, ActiveX. "Your Mileage May Vary".
Bob Schor
07-25-2018 07:31 AM - edited 07-25-2018 07:32 AM
Hi Bob, thanks for. taking the time and trying to help.
- Well, to answer your first questions, I'm going to attach to my response the excel workbook Im expecting from the labview program to create for me.
- About me VI, what I did is at a first glance, I didnt had the Save and Close modules, So all what the program was doing is opening my txt file in an excel workbook which was great because it's what I was looking for, but It didnt save it..
Im only a Labview beginner, So Im just trying whatever people say to me that I should give a hit. Im giving ActiveX now a chance cause I didnt found much on RGT. hope I can figure out a way because Im getting sick of it, It has been 3 days that Im trying different ways for this..
THanks
07-25-2018 07:55 AM
@haamza09 wrote:
Im giving ActiveX now a chance cause I didnt found much on RGT.
Did you find what I thought was an excellent "Revised" RGT code here in the LabVIEW Forums? I thought I was pretty clear on how to find it, but here is another way:
Incidentally, there have been reports on the Forum about problems with the RGT (and, for all I know, ActiveX) and Excel 2016. I'm using Excel 2013, and this code works fine. I believe the solution to the Excel 2016 issues is also in the LabVIEW Forums, but I don't have a reference to it.
Bob Schor
07-25-2018
07:58 AM
- last edited on
12-04-2024
02:10 PM
by
Content Cleaner
Usually, I use the right click > Export to Excel Method
which is suitable, as long as you don't have to batch-process more than 5 Excel files.
The following is from:
Moving Data From LabVIEW Into Excel
http://www.ni.com/newsletter/51339/de/
There are many different ways to move data from NI LabVIEW software into Microsoft Excel. Each method has advantages and drawbacks, so we’ll explore some of the available options to help you find the right one for your application.
Export |
TDMS File |
CSV File |
Report Gen. |
DIY ActiveX |
NI DIAdem |
|
Interactive |
√ |
|
|
|
|
√ |
Programmatic |
√1 |
√ |
√ |
√ |
√ |
√ |
Custom formatting |
|
|
|
√ |
√ |
√ |
Works without Excel being installed |
|
√ |
√ |
|
|
√ |
Automatically saves metadata |
|
√ |
|
|
|
√ |
Requires additional software |
|
√2 |
|
√3 |
|
√4 |
File based transfer |
|
√ |
√ |
|
|
√ |
Automation interface transfer |
√ |
|
|
√ |
√ |
√ |
1 data can be sent to Excel programmatically but requires manual action to save the file
2 requires the TDM Excel Add-In for Microsoft Excel – free to download and installs with recent versions of LabVIEW
3 requires the NI LabVIEW Report Generation Toolkit for Microsoft Office
4 requires DIAdem
07-25-2018 08:06 AM
I already seen it, but I dont really understand. It doesnt seem to be what Im looking for. All what I want is a tool that does open a txt file and save it as Excel. Your program seems to be so complex for me and for sure not what Im looking for. Thank you for your help though
07-25-2018 08:27 AM - edited 07-25-2018 08:54 AM
The Report Generation Toolkit is built on top of the Excel ActiveX interface. You can use this API either through direct ActiveX calls or the Microsoft.Office.Interop.Excel .NET assembly to automatically create Excel files. The code snippet below produces essentially the same result as the Report Generation Toolkit example but instead uses a .NET interop assembly to communicate with Excel. As you can see, the code ends up a little more complex but anyone with a background in ActiveX/.NET programming should feel right at home.
Here is the output of the above code snippet:
0# you need MS Excel 2007 or higher installed on your PC
1# get that demo to work**
2# modify the demo to your needs
If this is to complex for you (as you have said several times),
than maybe you should ask yourself, if this is the right task for a beginner.
** I had to manually re-select Microsoft.Office.Interop.Excel(15.0.0.0)>ApplicationClass()
see attached
07-25-2018 09:32 AM
I always save my data in a Tab delimited text file. Excel has no problem opening and importing text files natively. See my response to your original post.
07-25-2018 10:11 AM - edited 07-25-2018 10:15 AM
this snippet will create a .xlsx file named "Test file.xlsx" from a 2d String array** in the same place where the .vi is located
I use a 2d string array constant, which may be replaced with "Read delimited Spreadsheet.vi", to read a real .txt file
which version of LabView are you using?
07-25-2018 11:09 AM
You want to use the Workbooks.OpenText method.