LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Read excel cells into variables

Solved!
Go to solution

I am trying to read cells from an excel file and store the contents into variables. The idea is to pass in info such as test numbers, high/low limits, ect.

I've looked through the activex/excel samples and found excel2000dem which has a function called ReadDataFromExcel. I've copied that plus the

excel2000.h file, plus other variables and defines that it seemed to need. I get no errors for a build/compile but when I shift/F5, I get 7 link errors

for Undefined symbols such as '_ExcelSheetsItem @28' and '_ExcelWorkbooksOpen@208' .   I'm new to LabWindows so I'm not sure how to

track down a link error. Can someone point me in the right direction?

 

Mike

0 Kudos
Message 1 of 15
(5,512 Views)

You need to add the excel instrument. Go to Instrument at the top and select load instrument. Go into the activeX folder and then the excel folder. There will be two instruments: excel2000.fp and excelreport.fp. Load each one of those and then try your program and let me know if that works.

 

Tony 

0 Kudos
Message 2 of 15
(5,509 Views)

Yes, that fixed the above problem. Thank You!

 

Now, the next problem is I have 2 compile errors:

 

  1. When I call ReadDataFromExcel, I get a Missing prototype. (Require function prototypes build option is enabled.) error.

 

  2. At the ReadDataFromExcel function, I get a Redeclaration of 'ReadDataFromExcel' previously declared  error  which points to where I'm calling it.

 

Mike



 

0 Kudos
Message 3 of 15
(5,504 Views)

ok. The ReadDataFromExcel function is not defined in the excel instruments. Even though you selected to require prototypes, it doesn't make the prototypes. So up at the top before your main function, put a prototype for ReadDataFromExcel. I see in this example that many of the functions used are user made by the designer. Try including the prototype and let me know how it goes.

 

Tony 

0 Kudos
Message 4 of 15
(5,495 Views)

Tony,

 

Thanks, that seemd to work too. Odd thing is that I had closed the program and now that I've reloaded it, the instruments were not loaded anymore.

Should they stick when LabWindows is closed or do they need to be reloaded every time? Now that I've reloaded them, I've got the same original link

errors again for the undefined symbols.

 

Mike

 

0 Kudos
Message 5 of 15
(5,492 Views)

oh ya. Go into edit and roll over "add files to project" and then select the excel2000.fp and excelreport.fp instruments. This way they are included whenever you open up that project. See how this does.

 

Tony 

0 Kudos
Message 6 of 15
(5,488 Views)

Tony,

 

That fixed the issue with the instrument files being locked to the program. I'm still stuck back to the undefined symbol problem. I noticed that the demo program only uses excel2000.fp so I removed excelreport.fp . Still have the same problem. It's odd that it fixed it the first time around but now doesn't.

 

Mike

0 Kudos
Message 7 of 15
(5,472 Views)

Mike,

 

First make sure the excel2000.h file is in the include section at the top, otherwise can you post what the error says exactly and for what function? Thanks. 

0 Kudos
Message 8 of 15
(5,470 Views)

Tony,

 

Here are the error messages. I only get it when the ReadDataFromExcel function is in the program. If I comment out the function, there are no errors. 

 

7 Project link errors
 Undefined symbol '_Excel_GetProperty@20' referenced in "Sirius_rev1.c".
 Undefined symbol '_Excel_WorksheetActivate@8' referenced in "Sirius_rev1.c".
 Undefined symbol '_Excel_WorksheetRange@44' referenced in "Sirius_rev1.c".
 Undefined symbol '_Excel_SheetsItem@28' referenced in "Sirius_rev1.c".
 Undefined symbol '_Excel_WorkbooksOpen@208' referenced in "Sirius_rev1.c".
 Undefined symbol '_Excel_RangeActivate@12' referenced in "Sirius_rev1.c".
 Undefined symbol '_Excel_RangeGetItem@44' referenced in "Sirius_rev1.c".

 

 

Mike

0 Kudos
Message 9 of 15
(5,467 Views)
Solution
Accepted by topic author MikeD_3258
Alright, I think I've finally managed to narrow the issue down. It seems like the .c file for the instrument has been disconnected. Here is how to fix this. Go up to instruments and select edit. Then click Attach and Edit source. It will recompile and hopefully attach the excel2000.c to the instrument. Go ahead and try this. 
0 Kudos
Message 10 of 15
(5,463 Views)