I'm trying to write data into a cell, which has multiple line breaks (I believe ), the resulting .xlsx has line breaks removed. Is there a way to keep these line breaks?
The API for styles changed for openpyxl >= 2. The following code demonstrates the modern API.
from openpyxl import Workbook from openpyxl.styles import Alignment wb = Workbook() ws = wb.active # wb.active returns a Worksheet object ws['A1'] = "Line 1 Line 2 Line 3" ws['A1'].alignment = Alignment(wrapText=True) wb.save("wrap.xlsx")
1.4m articles
1.4m replys
5 comments
57.0k users