Trailing spaces in text are lost when reading workbook being previously saved

Issue #458 resolved
Alexander Vinnikov
created an issue

xml:space attribute is written to <si> element while reader expects it in text element <t> This attribute is expected to be scoped to child elements. Excel 2010 writes the attribute to <t> element.

Comments (8)

  1. Alexander Vinnikov reporter

    Here is sample code:

    import openpyxl
    sample_string = 'String with trailing space '
    wb = openpyxl.Workbook()
    ws =
    ws['A1'] = sample_string'test_trailing_space.xlsx')
    wb = openpyxl.load_workbook('test_trailing_space.xlsx')
    ws =
    assert ws['A1'].value == sample_string
  2. Andries Lof

    Hi, I'm using openpyxl 2.6 And i can't save 'trailing spaces' with save_workbook. I tried to implement the 'Correct the schema for saving strings.' as in 7bbe152e6e6c. I noticed the architecture changed a bit since the 2.2 branch Now a added the text.set(PRESERVE_SPACE, 'preserve') to

    regards, Andries

  3. Log in to comment