type of line break is changed after reopen of the file
Created originally on Bitbucket by Anonymous
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'