LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Entering Data collected and saved as a csv file into an existing excel file that has conditional formatting

Solved!
Go to solution

I am using Labview 2020 and I am recording data into a csv file from a Keysight DAQ.  I would like to pull this csv file and place the data into an existing excel file that has conditional formatting.  

0 Kudos
Message 1 of 8
(1,308 Views)

You need the Report Generation Toolkit ,. it will use Active X.

You can then insert data into the spreadsheet, and automate as you would do o excel. 

 

0 Kudos
Message 2 of 8
(1,286 Views)

The Forums has a Demo of the Report Generation Toolkit (Revised "Generate Excel Report" Example ) for generating a new Excel File.  It is also possible to open an existing Excel file and add new data to a WorkSheet, but this takes a little more work, especially if you are not quite sure where it needs to go

 

We can help, but you can help us help you by explaining what you need to do, and showing us a sample of the existing Excel Workbook that you want to use as your "template".

 

Bob Schor

 

 

0 Kudos
Message 3 of 8
(1,267 Views)

We are just taking the csv file and placing the data into the existing excel file that has conditional formatting to show if certain columns are out of range.  It's a very simple excel file used just so the technician can see if anything is out of spec. without creating a massive Labview program to do the same.

0 Kudos
Message 4 of 8
(1,248 Views)

OK, it won't be too difficult.  Here are some observations:

  • The .csv is, of course, entirely a text file.  You specify the precision when you write it.  In particular, your Time column shows "time" in minutes, so you have multiple lines having exactly the same time.  You can change how Time is saved by specifying that you want a Custom Time Format and specifying HH:MM:SS.  I also recommend that you choose 24-hour, so as not to have to contend with AM and PM, and the confusion of Noon and Midnight.  So modify the program that creates the .csv file.
  • LabVIEW and Excel save TimeStamps using different "rules".  But you are working with the "text" representation of the TimeStamp, where the text format can be "common" to both.  Everything in your Excel file is considered as Text, and will be formatted according to Excel's general rules, unless you override them.  Again, the Time entry will be the Problem Child.

Open your .csv file with Excel.  Notice that the Date/Time column shows ########.  If you widen it, it will show multiple lines with 6/12/2023 15:05 (because you aren't saving seconds).  Even if you were saving seconds, the default Excel format wouldn't show them.  So you need a "Custom Format".

 

Right-click the column header, "A", and choose "Format Cells".  Choose Custom.  Scan down until you find "m/d/yyyy h:mm".  Right-click to select it, and in the "Edit box" on top of the list of choices, add ":ss" and click "OK".  The seconds values will appear (they'll be ":00", of course, because you didn't save seconds, see above).

 

OK, we're almost done.  We discussed what you need to do to your Data Generating program to get seconds added to the saved Time, and discussed how to change your "Template" file to allow you to see the seconds when you create an Excel .xlsx version of your .csv data.  So the last step is getting Excel to save the data from the .csv file.

 

It is pretty simple.  Pretend you are going to write a new Excel file "from scratch", as shown in the "Generate Excel Report" example.  Notice the fourth Input (just above Error In), called "template (empty)".  Wire the path to your Template file (which you called "Excel Burn In with limits.xlsx").  It will open, and be available for you to write into it.  But don't worry, we are not going to modify the Template -- when the time comes to write, we will use "Save Report to File" and specify the "real" name we want to use for the .xlsx file, e.g. "Burn In #245.xlsx".

 

Bob Schor

Message 5 of 8
(1,239 Views)

search the example "Excel- Write Table.vi" and modify accordingly .  

Use method Open - wire the path to your excel file then adjust the cell position before inseerting the latest data. 

There may be a function to read the content of the sheet so you know where to place the latest data. 

 

* I'm not sure if this example is native to Labview or on NI Report Generation (i have it installed on my computer). 

 

 

eXCEL- Write Table - Modified.png

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

Thank you for all the help, I have been busy with other projects but I appreciate the help and I plan on getting back to this at some point this week.

 

Thanks again

0 Kudos
Message 7 of 8
(1,195 Views)
Solution
Accepted by topic author BGarber05

Thanks again for the suggestions.   I was able to come up with a solution.  I will show it below even though a few of the VIs are of my own making to record the data.

 

BGarber05_0-1687541346324.png

 

Message 8 of 8
(1,138 Views)