Open Source on IBM i

Write Unicode Characters with libxlsxwriter

Hi,

the project libxlsxwriter lets your programmatically create spreadsheets in the Open Document format which is also used by OpenOffice, Microsoft Office, ... .

Sometimes you need to add a special sign to some cell, f. e. the Euro currency symbol. If your native codepage does not support it you can still code it by escaping it. Characters can be escaped with the syntax _xHHHH_ where HHHH is the hex value of the unicode character, _x20AC_ for the euro sign.

This can again be escaped with escaping the first underscore with _x005F_. _x005F_x20AC_ will literally write the string and not the euro sign.

See Ecma Office Open XML Part 1 - Fundamentals and Markup Language Reference , 22.4.2.4 bstr (Basic String) at page 3736.

dcl-s moneyFormat pointer;

moneyFormat = workbook_add_format(workbook);
format_set_num_format(moneyFormat : '#,##0.00 "_x20AC_"');

worksheet_write_number(worksheet : 3 : 1 : 1499.99 : moneyFormat);

Happy escaping!

Mihael

Tags : libxlsxwriter