mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #467] Hang in workbook_close #364
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#364
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ronaldowww on GitHub (Dec 31, 2024).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/467
Originally assigned to: @jmcnamara on GitHub.
LXW_VERSION "1.1.8"
//insert image
if (PathFileExistsA((*iter).ImagePath.c_str()))
{
error = worksheet_insert_image_opt(worksheet3, excelRow, excelCol, (iter).ImagePath.c_str(), &options1);
if (error)
{
const char strerror = lxw_strerror(error);
WriteLog(LOG_FAILURE, "worksheet insert image %s error, %s.", (*iter).ImagePath.c_str(), strerror);
return;
}
}
else
{
WriteLog(LOG_FAILURE, "Cannot find image file %s.", (*iter).ImagePath.c_str());
}
error = workbook_close(workbook);
if (error)
{
const char* strerror = lxw_strerror(error);
WriteLog(LOG_FAILURE, "excel file close error, %s.", strerror);
return;
}
The callstack when hang issue happening is like the pic showing:

Could you give me some suggestion?
Thanks
@jmcnamara commented on GitHub (Dec 31, 2024):
@ronaldowww You will need to add a small complete program that demonstrates the issue. There is no way to guess just from a call trace like that.
@ronaldowww commented on GitHub (Jan 2, 2025):
Thanks for your quick response.
I have upload the complete method code that invoke the libxlsxwriter.
When the hang issue happened, from the printed log, I can see "ExportExcelReport sheet 3 done.", but no "ExportExcelReport end".
Please help check.
Thanks in advance!
@jmcnamara commented on GitHub (Jan 2, 2025):
This still isn't a small complete example that demonstrates the issue, so there is no way for me to figure out what the issue is.
However the program shouldn't be calling
workbook_close()in a loop since you can only close the file once. Restructure the code so thatworkbook_close()is outside the loop.@ronaldowww commented on GitHub (Jan 2, 2025):
workbook_close corresponds to the workbook_new one by one, though they are in a loop, I don't think this should be a problem.
The code I posted is the full method that is related to libxlsxwriter. And the hang issue doesn't happen every time.
Thanks!
@jmcnamara commented on GitHub (Jan 2, 2025):
Correct. That shouldn't be a problem.
If you can't reduce the code to a minimal runnable example that I can compile and run then I can't help you.
Instead I suggest:
CCenter::ExportExcelReport()from a thread since libxlsxwriter isn't thread safe.worksheet_insert_image_opt()code or theworksheet_merge_range()code.@ronaldowww commented on GitHub (Jan 6, 2025):
Thanks for your response. I'll update you if I can reproduce the issue in a runnable example.