标签:book int val 修改 xlsx work 引入 方法 使用
1)引入库
2)新建工作簿
3)打开已有工作簿
4)获得sheet控制句柄
5)sheet属性
6)循环-Sheet
for sheet in wb: print(sheet.title)
7)选取Cell
8)循环-Cell
>>> for row in ws.iter_rows(min_row=1, max_col=3, max_row=2): ... for cell in row: ... print(cell) <Cell Sheet1.A1> <Cell Sheet1.B1> <Cell Sheet1.C1> <Cell Sheet1.A2> <Cell Sheet1.B2> <Cell Sheet1.C2>
>>> for col in ws.iter_cols(min_row=1, max_col=3, max_row=2): ... for cell in col: ... print(cell) <Cell Sheet1.A1> <Cell Sheet1.A2> <Cell Sheet1.B1> <Cell Sheet1.B2> <Cell Sheet1.C1> <Cell Sheet1.C2>
9)数据保存
>>> c.value = ‘hello, world‘ >>> print(c.value) ‘hello, world‘ >>> d.value = 3.14 >>> print(d.value) 3.14
>>> wb = Workbook(guess_types=True) >>> c.value = ‘12%‘ >>> print(c.value) 0.12 >>> import datetime >>> d.value = datetime.datetime.now() >>> print d.value datetime.datetime(2010, 9, 10, 22, 25, 18) >>> c.value = ‘31.50‘ >>> print(c.value) 31.5
A)保存文件
标签:book int val 修改 xlsx work 引入 方法 使用
原文地址:https://www.cnblogs.com/CodeUnknown/p/9729480.html