標籤:資料 auto color fit stream str ice 編輯 vertica
xlutils用於對excel的修改,xlwt不能用於修改excel檔案,只能建立新的excel檔案
xlrdBook(class) 由xlrd.open_work("example.xls")返回
nsheets: sheets數
sheet_names: sheet名稱列表
sheets: sheet列表
sheet_by_index(sheetx): 按序號提取sheet
sheet_by_name(sheet_name): 按名稱提取sheet
Sheet(class) 由Book object相關方法返回
name: sheet名
nrows: 行數
ncols: 列數
cell(rowx,colx): 第rows行colx列的儲存格
cell_type(rowx,colx): 資料類型
cell_value(rows,colx): 數值
col(colx): 第colx列所有儲存格組成的列表
col_slice(colx,start_rowx=0,end_rowx=None): 第colx列指定儲存格組成的列表
col_types(colx,start_rowx=0,end_rowx=None): 第colx列指定儲存格數實值型別組成的列表
col_values(colx,start_rowx=0,end_rowx=None): 第colx列指定儲存格數值組成的列表
row同樣有col的各項操作,此處略去
Cell(class) 由Sheet object(s)相關方法返回
ctype: 一個int型變數,對應不同的數實值型別
value: 儲存格的值
xlwtWorkbook(class) 由xlwt.Workbook()返回
encoding: 編碼方案
add_sheet(sheet_name): 添加sheet
get_sheet(Sheet_name): 選擇sheet
save(file_name): 儲存
Worksheet(class) 由Workbook object相關方法返回
write(rows,colx,cell_value,style): 編輯儲存格
row(rowx).write(colx,cell_value,style): 編輯行
flush_row_data(): 減少記憶體壓力,flush之前行不可再修改
col(colx),write(rows,cell_value,style): 編輯列
easyxf(function) 建立XFStyle instance,格式控制
expression syntax: (<element>:(<attribute> <value>,)+;)+
<element> - <attribute> - <value>:
(加粗為預設格式,以下所列並非全部)
font - bold - True or False
- colour - {colour}
- italic - True or False
- name - name of the font, Arial
- underline - True or False
alignment - direction - general, lr, rl
- horizontal - general, left, center, right, filled
- vertical - bottom, top, center, justified, distributed
- shrink_to_fit - True or False
bolders - left - an integer width between 0 and 13
- right - an integer width between 0 and 13
- top - an integer width between 0 and 13
- bottom - an integer width between 0 and 13
- diag - an integer width between 0 and 13
- left_colour - {colour}*, automatic colour
- right_colour - {colour}*, automatic colour
- ...
pattern - back_color - {colour}*, automatic colour
- fore_colour - {colour}*, automatic colour
- pattern - none, solid, fine_dots, sparse_dots
{colous}*: black, (dark_)(light_)blue, gold, (dark_)(light_)green, ivory, lavender,
(light_)orange, pink, (dark_)red, rose, violet, white, (dark_)(light_)yellow, ...
xlutils
copy: 將xlrd.Book轉為xlwt.Workbook
styles: 讀取xlrd.Workbook的每一個儲存格的style
display: 簡單而安全地呈現xlrd讀取的資料
filter: 拆分與整合多個xls檔案
margins: 查看錶格稀疏程度
save: 序列化xlrd.Book,轉存為binary xls或stream
python操作excel