You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Working in VS Community Edition 2022, I have successfully built OpenXLSX through CMake and DOxygen docs, run all demo programs as console apps.
I need to use OpenXLSX in an existing legacy MFC application. In Debug I can successfully open a workbook and worksheet and iterate through the rows and can view the contents of XLRow. However, as soon as I change the code to read the values in a row, a debug assertion is thrown.
Here is the code snippet:
void CBeckyDlg::ReadExcelFile(const CString sExcelFileName)
{
CString sTemp;
XLDocument doc;
// need to convert from CString to std::string
std::string s((LPCTSTR)sExcelFileName);
doc.open(s);
// open the worksheet note hard-wired name, need to fix
auto wksDE = doc.workbook().worksheet("AllDEData_7_9_2023");
int column_count = wksDE.columnCount();
int row_count = wksDE.rowCount();
// write the worksheet size to the output file
sTemp.Format("Excel File %s Rows %d Columns %d\n", sExcelFileName, row_count, column_count);
gOutputFile.WriteString(sTemp);
gOutputFile.Flush();
int rowcounter = 0;
XLRow tempXLRow;
std::list<XLCellValue> writeValues;
// iterate through the first 10 rows of the worksheet
for (auto& row : wksDE.rows()) {
rowcounter++;
tempXLRow = row;
//writeValues = tempXLRow.values(); // PROBLEM HERE IF I UNCOMMENT
if (rowcounter > 10)
break;
sTemp.Format("Excel Row %d\n", rowcounter);
gOutputFile.WriteString(sTemp);
gOutputFile.Flush();
}
doc.close();
return;
}`
This code, when run with the writeValues=tempXLRow.values() line commented out, generates output as it should:
Excel File C:\ProgramData\Beachfx\Data\AllDEData_7_9_2023.xlsx Rows 1075 Columns 27
Excel Row 1
Excel Row 2
Excel Row 3
Excel Row 4
Excel Row 5
Excel Row 6
Excel Row 7
Excel Row 8
Excel Row 9
Excel Row 10
The error that is thrown is:
Program: C:\Projects\BeachFx\BeachFxCodeWorkingCopy\Debug\BeachFx.exe
File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
Line: 996
Expression: __acrt_first_block == header
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
The thread 0x1488 has exited with code 0 (0x0).
The thread 0x3a94 has exited with code 0 (0x0).
The thread 0x60c has exited with code 0 (0x0).
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in BeachFx.exe.
Debug Assertion Failed!
Program: C:\Projects\BeachFx\BeachFxCodeWorkingCopy\Debug\BeachFx.exe
File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
Line: 996
Expression: __acrt_first_block == header
I just need a workaround so that I can extract the non-homogeneous row data (columns are variously numbers, strings, dates) from the returned std::list.
Note that I have tried various attempts from the demo examples, the above code snippet is the simplest I have found that allows the needed iteration through the rows.
The text was updated successfully, but these errors were encountered:
Thank you for this suggestion. I am still trying to work through it, not there yet.
Do you know if it is also necessary to modify the build of OpenXLSX through CMake for debug? I am building as a static library, would this be better as a shared library?
it’s been some time, I used visual studio cmake tools to generate CMakeSettings.json. for debug and release
I am also using a static library, which I think it’s better because of whole program optimization
Working in VS Community Edition 2022, I have successfully built OpenXLSX through CMake and DOxygen docs, run all demo programs as console apps.
I need to use OpenXLSX in an existing legacy MFC application. In Debug I can successfully open a workbook and worksheet and iterate through the rows and can view the contents of XLRow. However, as soon as I change the code to read the values in a row, a debug assertion is thrown.
Here is the code snippet:
The text was updated successfully, but these errors were encountered: