Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5339

ExcelRpt_ReadData crashing when it encounters excel cell error

$
0
0

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.


Viewing all articles
Browse latest Browse all 5339

Trending Articles