From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-11-2016 02:58 PM
I'm using CVI 2013 sp2 to read in values from an excel spreadsheet.
Usually the program runs just fine, but if there is a cell error (e.g. #REF!, or #DIV/0!) in the second row or later it crashes. Strangely, it works just fine if the first row has the cell error, it's just the second row that crashes it.
It looks like in the CVI built in function ExcelRpt_ReadData in excelreport.c detects the cell error and tries to use the error catching to exit the function. Once it triggers the error catching it tries to release the memory it had allocated and crashes because the memory has not actually been populated with the contents of the cells with #REF! errors. That memory release is on line 2086 of excelreport.c.
The error it throws is:
FATAL RUN-TIME ERROR: "c:\...\toolslib\activex\excel\excelreport.c", line 2086, col 13, thread id 0x000032BC: The program has caused a 'General Protection' fault at 0x7714E43E.
I've attached a project which demonstrates the problem. To run it, you'll have to change PATH on line 18 to the full path of the excel file included in the .zip. I included 3 Excel files, one ends with Good, because the program runs as desired with that one. With the next one, Medium, it runs fine despite the #REF error in the 1st row, which is what I want it to do. For the third one, Bad, it crashes since the #REF is on the 2nd row. You can easily choose which to run by changing which line is uncommented.
Guidance on how to get it to exit politely (like it does for Medium) for Bad instead of crashing would be greatly appreciated.
07-12-2016 02:53 PM
Hi AaronAnd,
I tried to run your code, but the build is failing due to undefined symbols referenced in the Demo.obj file. Are you getting this error as soon as you read the cell or is it post-pulling the data?
07-12-2016 03:01 PM
I just tried opening what I had uploaded, and I got the same issue. To fix this you need to load the excelreport instrument which is found in C:\Program Files (x86)\National Instruments\CVI2015\toolslib\activex\excel\excelreport.fp by default. I guess I just loaded the instrument in that session instead of adding it to the project, sorry about that.
Thanks for looking into this issue!
07-13-2016 03:53 PM
Do you know how many times you can read from the excel file without it breaking or is it the first time it hits the first #REF! after not reading one at the beginning?
It looks like somehow you end up pointing to memory that the ExcelRpt_ReadData is trying to free and that is calling the General Protection fault.
07-13-2016 04:36 PM
If there are no cell errors in the excel file, it can read many lines (multiple hundred) and not crash. If it hits a cell error anywhere but the first line of data it crashes. The crash is certainly triggered by trying to free memory, I just can't figure out why it's different if it's on the first line or a later line.
07-14-2016 06:13 PM