If I open a file with a data table and then call CalculateFormula(), it crashes with an exception “at the address 0x00000000”. If I remove the data table the problem disappears. Here is an example of the source code:
#include #include #include “windows.h”
#include “Aspose.Cells.h”
using namespace Aspose::Cells; #pragma comment(lib, “…/aspose/Aspose.Cells.lib”)
It seems that you are encountering a crash when calling the CalculateFormula() method on a workbook that contains a data table. This issue may be related to the default stack size limitations in your environment, which can lead to a System.StackOverFlowException.
To address this problem, you can try the following approaches:
Increase Stack Size: If you are running this code in an environment like IIS, the default stack size may be too small. You can create a new thread with an increased stack size and execute the CalculateFormula() method within that thread. This can help prevent stack overflow errors.
Use Calculation Monitor: Aspose.Cells provides a class called AbstractCalculationMonitor that can help you track formula calculations. By utilizing this class, you can monitor the stack size during calculations and potentially identify where the overflow occurs. However, be aware that checking the stack for every cell may impact performance.
Here is a basic example of how you might implement a thread with increased stack size:
#include <thread>
void CalculateWithIncreasedStack(Workbook& book) {
book.CalculateFormula();
}
int main(int argc, const char* argv[]) {
// ... (initialization code)
// Create a thread with increased stack size
std::thread calculationThread(CalculateWithIncreasedStack, std::ref(book));
calculationThread.join(); // Wait for the thread to finish
// ... (rest of your code)
}
Make sure to adjust the stack size according to your needs when creating the thread. This should help mitigate the crashing issue you are experiencing.
If the problem persists, consider checking for any updates or patches for Aspose.Cells, as they may have addressed similar issues in newer versions.
Could you please zip and attach the template Excel file here. We will check your issue soon. Additionally, it would be helpful if you could provide a standalone sample application (source code without compilation errors) along with the necessary resource file(s) to replicate the issue on our end.
P.S. Please ensure that the zipped archive of the project/application does not include the license file.
I tested with the simplest code and it works fine. I do not get any exception on Workbook.CalculateFormula() method. The output Excel file is generated fine as well.
e.g., Sample code:
Aspose::Cells::Startup();
//Source directory path
U16String dirPath(u"..\\Data\\LoadingSavingAndConverting\\");
//Output directory path
U16String outPath(u"..\\Data\\Output\\");
//Path of input excel file
U16String srcReadWriteXLSX = dirPath + u"_test.xlsx";
//Path of output excel file
U16String outReadWriteXLSX = outPath + u"out1.xlsx";
//Read source xlsx file
Workbook wb(srcReadWriteXLSX);
wb.CalculateFormula();
//Save the workbook in XLSX format
wb.Save(outReadWriteXLSX, SaveFormat::Xlsx);
//Stop before exiting
printf("\nProgram Finished. Press Enter to Exit....");
Aspose::Cells::Cleanup();
Please find attached the output XLSX file in the zipped archive for your reference. out1.zip (9.2 KB)
Which Aspose.Cells for C++ version you are using? Please try using newer versions (if you are not already using it).
After further evaluation, I am able to reproduce the issue with latest version/fix, i.e., Aspose.Cells for C++ v25.2 (previously I was using Aspose.Cells for C++ v24.12 which did not give any exception and worked fine) as you mentioned when using your template Excel file. I found it crashed on Workbook.CalculateFormula() method if the workbook has a data table in it. I got the exception:
Exception thrown at 0x0000000000000000 in CellsCPP.exe: 0xC0000005: Access violation executing location 0x0000000000000000
We require through evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSCPP-1157
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.