LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting xml file into excel

Hey,

Sorry if this is a repeat question but I can't seem to find the answer I am looking for. I have created an xml file that is full of arrays now I want a nice way to display them via excel. I was reading in the forums that you can just right click on the xml file and tell it to open with excel and that will convert it but for some reason my computer doesn't want to let me do that. As easy as that sounds I would rather have a vi that does it for me automaticly and my manager would like to see it this way too. We have been using python scripts but we want to make it pure labview and teststand. Can anyone show me an example of this using labview (via activex or something like it)?

 

Thanks,

dlovell

0 Kudos
Message 1 of 8
(6,544 Views)

In LabVIEW you'll have to parse the XML first to get your array.  LabVIEW has some built-in XML functions as does OpenG.  My current favorite is to use the Spreadsheet String to Array function and make the XML tag the delimiter.

 

Then just use the Report Generation Toolkit to place it all in Excel.

Chris
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 2 of 8
(6,537 Views)

I recall that VI Engineering once created an Excel plugin that did this.  It did it well!  Long ago.....Many versions of both LabVIEW and Office have pssed since then but the plugin was sound!  I was a client's user.

 

(OK. VIE just got their first plug (kudos) from me)...  I still call them bad names on good days.  But, they may still have a method.  Check the NI Alliance partners site.


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 8
(6,535 Views)

Hey Guys,

I am very new at Labview. I know that we here don't have the report generation toolkit and all of the examples I can find use the tool-kit. I have also tried to walk myself through ActiveX and learn how to use it but I am not able to. Does anyone have an example I can see using ActiveX so I can gain a better understanding of its components?

 

Thanks,

dlovell

0 Kudos
Message 4 of 8
(6,516 Views)

save it as a csv file.  

 

CSV files can be opened with excel

0 Kudos
Message 5 of 8
(6,504 Views)

I understand that some files can just be opened in excel, but I am hoping to keep everything automated so when I hit run on my test my test will go on its own and when it is finished an excel document will be open with all of my data nice and neat on the spread sheet. I am able to open and excel file and a new worksheet but I don't know how to get ActiveX to convert an xml file into excel. Does anyone have an example or know where one is that answers my last three post? Please and thank you.

 

dlovell

0 Kudos
Message 6 of 8
(6,490 Views)

Can you share one XML file to let us know about data format. Then may be I will be able to quickly develop some example.

Tushar Jambhekar
tushar@jambhekar.com

Jambhekar Automation Solutions
LabVIEW Consultancy, LabVIEW Training
Rent a LabVIEW Developer, My Blog

0 Kudos
Message 7 of 8
(6,467 Views)

@dlovell wrote:

I understand that some files can just be opened in excel, but I am hoping to keep everything automated so when I hit run on my test my test will go on its own and when it is finished an excel document will be open with all of my data nice and neat on the spread sheet. I am able to open and excel file and a new worksheet but I don't know how to get ActiveX to convert an xml file into excel. Does anyone have an example or know where one is that answers my last three post? Please and thank you.

 

dlovell


You are not going to find an ActiveX function to convert the XML file into Excel because it doesn't exist. You have to parse the XML file yourself and write it out to Excel manually. There is no 1-to-1 correspondence between an XML file and an Excel workbook. You're trying to compare a watermelon to a chair. To read the XML file and to get it into arrays you have numerous options:

  • JKI's Easy XML
  • LabVIEW XML Parser VIs
  • LabXML (free toolkit)
  • Parse it yourself using the text read function.

Once you read the XML file you then have to write it out to a flat form (i.e., a worksheet into a workbook), assuming the data goes into a single worksheet. For that you need ActiveX. You said you don't have the Report Generation Toolkit, so you have to code it up yourself. There's an example that ships with LabVIEW on writing data to Excel. You can also find a simple toolkit in the Excel thread, as well as a ton of links to other examples. NOTE: DO NOT POST QUESTIONS IN THE EXCEL THREAD!!! IT IS A THREAD OF LINKS TO EXAMPLES ONLY!!!!

0 Kudos
Message 8 of 8
(6,449 Views)