Issue CustomProperties in Excel (.xls): name saved in invalid unicode

Aug 30, 2013 at 12:44 PM
Edited Sep 2, 2013 at 10:05 AM
I want to add name-value pairs in the CustomProperties of an 97-2003 (.xls) Excel spreadsheet. Adding works, but name is inserted as invalid unicode (A is inserted as \u4100 instead of \u0041). The name is not not readable anymore (looks like chinese characters).
Name should be UTF-8 (single byte) of correct unicode for use in Excel 97-2003.
Before:
Image
After:
Image
Does anyone have experience with this?
var filename_in = Path.Combine(@"Z:\WSH projecten\Volleybal", "template.xls");
var fs_in = new FileStream(filename_in, FileMode.Open, FileAccess.Read);
var wb = new HSSFWorkbook(fs_in);

CustomProperties customProperties = wb.DocumentSummaryInformation.CustomProperties;
if (customProperties == null)
  customProperties = new CustomProperties();
customProperties.Put("A", "value A");
customProperties.Put("BB", "value BB");
customProperties.Put("CCC", "value CCC");
wb.DocumentSummaryInformation.CustomProperties = customProperties;

var filename_out = Path.Combine(@"Z:\WSH projecten\Volleybal", "result.xls");
var fs_out = new FileStream(filename_out, FileMode.Create);
wb.Write(fs_out);
fs_out.Close();
Coordinator
Oct 8, 2013 at 5:18 PM
It looks to be a bug because of incorrect sequence of high byte and low byte.
Coordinator
Oct 8, 2013 at 5:19 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.