[GH-ISSUE #121] worksheet_write_string raises error for empty string string #102

Closed
opened 2026-05-05 11:40:47 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @jeroen on GitHub (Aug 22, 2017).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/121

Originally assigned to: @jmcnamara on GitHub.

I found that worksheet_write_string() raises an error when inserting an empty string "" value:

 NULL function parameter ignored.

In my data the empty string "" is an actual value and different from no value NULL. Does Excel not support empty strings?

Originally created by @jeroen on GitHub (Aug 22, 2017). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/121 Originally assigned to: @jmcnamara on GitHub. I found that `worksheet_write_string()` raises an error when inserting an empty string `""` value: NULL function parameter ignored. In my data the empty string `""` is an actual value and different from no value `NULL`. Does Excel not support empty strings?
gitea-mirror 2026-05-05 11:40:47 -06:00
Author
Owner

@jmcnamara commented on GitHub (Aug 22, 2017):

Does Excel support empty strings?

No.

Excel ignores empty strings unless it has a format. This allows you to format blank cells as part of a formatted area. But blank or empty strings without formatting are never stored by Excel.

So libxlsxwriter returns an error/warning to let the user know that the parameter is being ignored.
However, the error probably isn't correct in this case since you aren't passing a NULL. It should probably say something like:

 Empty or NULL string without formatting is ignored.

I'll add a new warning for that.

<!-- gh-comment-id:323997957 --> @jmcnamara commented on GitHub (Aug 22, 2017): > Does Excel support empty strings? No. Excel ignores empty strings **unless** it has a format. This allows you to format blank cells as part of a formatted area. But blank or empty strings without formatting are never stored by Excel. So libxlsxwriter returns an error/warning to let the user know that the parameter is being ignored. However, the error probably isn't correct in this case since you aren't passing a `NULL`. It should probably say something like: Empty or NULL string without formatting is ignored. I'll add a new warning for that.
Author
Owner

@jeroen commented on GitHub (Aug 22, 2017):

So the only way to store an empty string is make it e.g. bold?

<!-- gh-comment-id:323999636 --> @jeroen commented on GitHub (Aug 22, 2017): So the only way to store an empty string is make it e.g. bold?
Author
Owner

@jmcnamara commented on GitHub (Aug 22, 2017):

So the only way to store an empty string is make it e.g. bold?

Yes. A empty string without formatting isn't stored by Excel. It just ignores them.

<!-- gh-comment-id:324005717 --> @jmcnamara commented on GitHub (Aug 22, 2017): > So the only way to store an empty string is make it e.g. bold? Yes. A empty string without formatting isn't stored by Excel. It just ignores them.
Author
Owner

@jmcnamara commented on GitHub (Aug 30, 2017):

I'll add a new warning for that.

After thinking about this for a bit I've changed the code to just ignore unformatted empty or NULL strings without a warning/error. This is in line with what Excel does.

<!-- gh-comment-id:325849956 --> @jmcnamara commented on GitHub (Aug 30, 2017): > I'll add a new warning for that. After thinking about this for a bit I've changed the code to just ignore unformatted empty or NULL strings without a warning/error. This is in line with what Excel does.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#102
No description provided.