[GH-ISSUE #276] Issue with writing special characters to xlsx file. #220

Closed
opened 2026-05-05 11:58:44 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @StephenRademaker on GitHub (Mar 13, 2020).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/276

Originally assigned to: @jmcnamara on GitHub.

Issue with writing special characters to xlsx file.

I am using libxlsxwriter version 0.9.4.
I have build the library according to CMake and also via vcpkg as described in the document (x86 and x64 release). However in all cases I get the same error.

I am using Visual Studio 2019 version 16.4.6
Platform Toolset: Visual Studio 2019 v142
With the compiler Visual C++

Here is some code that demonstrates the problem:

#include "xlsxwriter.h"

int main() {

lxw_workbook  *workbook  = workbook_new("bug_report.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

worksheet_write_string(worksheet, 0, 0, "Hello", NULL);
worksheet_write_number(worksheet, 1, 0, 123, NULL);
worksheet_write_string(worksheet, 2, 0, "é", NULL);
worksheet_write_string(worksheet, 3, 0, "ë", NULL);

return workbook_close(workbook);

}

The problem occurs when you open the xlsx file in Microsoft Excel.
Then comes the following message:

Removed Part: /xl/sharedStrings.xml part with XML error. (Strings) Illegal xml character. Line 2, column 128.
Removed Records: Cell information from /xl/worksheets/sheet1.xml part

It seems that special characters like "é" and "ë" are not written correctly, despite of the worksheet_write_string function not giving an error.

Is this a bug or am I doing something wrong?

Awaiting your reply, thank you in advance, greetings, Stephen.

Originally created by @StephenRademaker on GitHub (Mar 13, 2020). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/276 Originally assigned to: @jmcnamara on GitHub. Issue with writing special characters to xlsx file. I am using libxlsxwriter version 0.9.4. I have build the library according to CMake and also via vcpkg as described in the document (x86 and x64 release). However in all cases I get the same error. I am using Visual Studio 2019 version 16.4.6 Platform Toolset: Visual Studio 2019 v142 With the compiler Visual C++ Here is some code that demonstrates the problem: #include "xlsxwriter.h" int main() { lxw_workbook *workbook = workbook_new("bug_report.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_write_string(worksheet, 0, 0, "Hello", NULL); worksheet_write_number(worksheet, 1, 0, 123, NULL); worksheet_write_string(worksheet, 2, 0, "é", NULL); worksheet_write_string(worksheet, 3, 0, "ë", NULL); return workbook_close(workbook); } The problem occurs when you open the xlsx file in Microsoft Excel. Then comes the following message: Removed Part: /xl/sharedStrings.xml part with XML error. (Strings) Illegal xml character. Line 2, column 128. Removed Records: Cell information from /xl/worksheets/sheet1.xml part It seems that special characters like "é" and "ë" are not written correctly, despite of the worksheet_write_string function not giving an error. Is this a bug or am I doing something wrong? Awaiting your reply, thank you in advance, greetings, Stephen.
gitea-mirror 2026-05-05 11:58:44 -06:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jmcnamara commented on GitHub (Mar 21, 2020):

It seems that special characters like "é" and "ë" are not written correctly, despite of the worksheet_write_string function not giving an error.

Excel, and libxlsxwriter, only support UTF-8 for non ASCII characters. See the docs on worksheet_write_string() and this utf8.c example.

It will work in Visual Studio if you use a UTF-8 encoded file. You may, or may not, also need to tell VS that your file is UTF-8 encoded.

<!-- gh-comment-id:602074091 --> @jmcnamara commented on GitHub (Mar 21, 2020): > It seems that special characters like "é" and "ë" are not written correctly, despite of the worksheet_write_string function not giving an error. Excel, and libxlsxwriter, only support UTF-8 for non ASCII characters. See the docs on [worksheet_write_string()](https://libxlsxwriter.github.io/worksheet_8h.html#ac208046e7a6d12cc87982422efa41b31) and this [utf8.c example](https://libxlsxwriter.github.io/utf8_8c-example.html#a4). It will work in Visual Studio if you use a UTF-8 encoded file. You may, or may not, also need to tell VS that your file is UTF-8 encoded.
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#220
No description provided.