Closed setminami closed 6 years ago
In [1]: import openpyxl
In [2]: book = openpyxl.load_workbook('./Samples/cheatsheet.xlsx', keep_vba=True, data_only=False)
In [3]: book
Out[3]: <openpyxl.workbook.workbook.Workbook at 0x10c1c4860>
In [4]: sheets = book.worksheets
In [6]: root = sheets[1]
In [7]: root
Out[7]: <Worksheet "root">
In [8]: rows = root.iter_rows()
In [13]: rowarray = [r for r in rows]
In [15]: l2 = rowarray[1]
In [17]: cell = l2[0]
In [18]: cell
Out[18]: <Cell 'root'.A2>
In [21]: cell.encoding
Out[21]: 'utf-8'
この設計だと書き込み時に、違うcodeで混ぜ込めてしまうところだけ注意
book, sheetにもencodingあり
In [22]: root.encoding
Out[22]: 'utf-8'
In [23]: book.code_name
>> 空
In [24]: book.encoding
Out[24]: 'utf-8'
openpyxlにおける文字コードの扱い