LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create new Excel workbook

Hello,

 

How do you go about creating a new excel workbook if one does not exist within LabVIEW.  Currently, I have to manually create an excel file then copy that path into LabVIEW for the program to run.  I wanted to generate a new Excel file within LabVIEW.

 

Thanks.

0 Kudos
Message 1 of 20
(6,300 Views)

Well I have to say I have never used the LabVIEW report generation toolkit because it requires Word or Excel to be installed on the target machine to work. But this example (Excel Report - Conditionally Formatted Spreadsheet.vi) shows how to create a new Excel workbook.

 

I prefer the third party add-on XLR8 over the LabVIEW Excel toolkit.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 20
(6,294 Views)

Leave the template input of the first VI (New Report.vi) unwired, and it will create a new file.

 

Do use the template when you have specific formatting and named ranges that you want to insert into, but then you would make the save file name different so you don't overwrite it.

Message 3 of 20
(6,285 Views)

Hello,

 

Is there a similar function for the Excel workbook creation like that in the "File IO" tab:

 

 Capture.PNG

 

The situation that I would like to be in, is that if you can just type in a name in the file Location and the new file will be created.  I tried the "Create File" from the File IO but I get an error, "Exception occured in Microsoft Office Excel: Excel cannot open the file 'NI_Excel_Tab.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file...".  I have attached the updated code.

0 Kudos
Message 4 of 20
(6,259 Views)

Not a single function, you would use 2 functions together:

temp.PNG

But I don't see much advantage to creating a blank file rather than just saving it once it is populated.

Message 5 of 20
(6,245 Views)

Here is one of my use case:

 

To generate a file name based on tests being carried out.  Once the file is created (with an automatically generated name), data is taken and appended to the file until certain test conditions are met.  That is, this loop can be accessed multiple times under the same filename condition.  If at first, the file does not exist, it should be automatically created.

 

With the approach that you gave, can the above condition be satisfied?

 

Thanks,

hiNi.

0 Kudos
Message 6 of 20
(6,235 Views)

Yes, I just keep the report in the shift register as you are doing. I would also keep track of the "next cell bottom left" if appending tables, to make sure you don't overwrite previous data. You could also use the "get last row" vi if you like.

 

temp.PNG

 

If you don't need any fancy excel formatting, you could also use .csv files with the "write to spreadsheet / write delimited file" vis, which is what I usually do. 

0 Kudos
Message 7 of 20
(6,230 Views)

I am still having issues with generating a new excel file if one does not exist.  Can you tell me how I can fix the attached code to generate a new excel workbook by just typing in a new name in the "File Location"?  Not sure why I get the error code "7"?

 

Thanks,

hiNi.

0 Kudos
Message 8 of 20
(6,222 Views)

If you wire the filename in as a template, it's going to use that file as a starting point. That's fine, if the file exists. If not, it should give you an error.

 

If the file does not exist, you should leave the terminal unwired, or use an empty path constant.

 

temp.PNG

Message 9 of 20
(6,219 Views)

What function is that "anchor looking" icon?  I have never used that before.

0 Kudos
Message 10 of 20
(6,215 Views)