setminami / Jsonica

to construct huge json data simply.
https://setminami.github.io/Jsonica/
MIT License
0 stars 2 forks source link

xlsx codec仕様調査 #20

Closed setminami closed 6 years ago

setminami commented 6 years ago

openpyxlにおける文字コードの扱い

setminami commented 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'
setminami commented 6 years ago

この設計だと書き込み時に、違う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'