Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug: workbook_add_worksheet does not return a reasonable worksheet #443

Closed
wxie7 opened this issue May 8, 2024 · 1 comment
Closed

Bug: workbook_add_worksheet does not return a reasonable worksheet #443

wxie7 opened this issue May 8, 2024 · 1 comment
Assignees

Comments

@wxie7
Copy link

wxie7 commented May 8, 2024

There may be a semantic bug here. When name is NULL, but the same name has been written before, a worksheet with a new valid name should be returned.

#include "xlsxwriter.h"
int main() {
    lxw_workbook  *workbook  = workbook_new("demo.xlsx");
    const char* name[] = {"Sheet1", "Sheet2", "Sheet4", NULL};
    for (int i = 0; i < sizeof(name) / sizeof(*name); ++i) {
      if (name[i] == NULL || workbook_validate_sheet_name(workbook, name[i]) == LXW_NO_ERROR) {
        lxw_worksheet *worksheet = workbook_add_worksheet(workbook, name[i]);
        if (worksheet == NULL) {
          __builtin_trap();
        }
      }
    }
    return 0;
}
@jmcnamara jmcnamara self-assigned this May 8, 2024
@jmcnamara
Copy link
Owner

For me this isn't a bug. The default sheet naming is intended to be simple and incremental. If the user has a scenario where they want to use one of the default names out of sequence then they should avoid using default naming or at least add some logic to avoid this issue.

Closing as won't fix.

@jmcnamara jmcnamara closed this as not planned Won't fix, can't repro, duplicate, stale May 8, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants