type of line break is changed after reopen of the file

Issue #263 resolved
Anonymous created an issue

Each carriage return \r character is changed to a new line \n character after reopen of the excel file. This is a problem because this transformation of the line break causes an unexpected change of the cell value. Thus, each comparison of the written value and read value will produce an unexpected result.

Version 1.8.2

Please try this to reproduce the problem:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

from openpyxl import Workbook from openpyxl import load_workbook wb=Workbook() ws=wb.get_active_sheet() ws.cell(row=1, column=1).value='aaa\rbbb\nccc' print(ws.cell(row=1, column=1).value) bbb ccc ws.cell(row=1, column=1).value 'aaa\rbbb\nccc' wb.save(r'd:\temp\test.xlsx') ws=None wb=None wb2=load_workbook(r'd:\temp\test.xlsx') ws2=wb2.get_active_sheet() print(ws2.cell(row=1, column=1).value) aaa bbb ccc ws2.cell(row=1, column=1).value 'aaa\nbbb\nccc' ========================= Problem: 'aaa\nbbb\nccc' is returned instead of 'aaa\rbbb\nccc'

Comments (5)

  1. CharlieC
    • changed version to 1.9.x

    If we have no clear reason for the choice then we should write some test cases (mainly see if we can roundtrip files) and see if we can't remove the restriction.

  2. CharlieC

    Removed conversion of line breaks as there seems to be no reason for it in Excel. This was copied in the original port from PHPExcel. Maybe it relates to a simple output check. Excel doesn't seem to support entering line breaks manually but it will render them correctly. Resolves #263

    → <<cset 338c2d343cd3>>

  3. Log in to comment