writeexcelwithpythonxlwt,


write excel with python xlwt

1. install

pip install xlwt

2. xlwt.Workbook Object

他有2个常用的方法,一个就是save 方法来保存的,还有一个就是add_sheet 添加工作表。
1. save
2. add_sheet

3. Worksheets Object

是由Workbook这个对象创建出来的。可以直接write写cell 。也可以返回Rows 这个类,然后由Rows 来write cell。

4. 3种写cell的方式:

Worksheet.write(row_index,column_index,value) Row.write(column_index,value) Specialist write methods on the Row class

5. 直接用write的方法的实例

写个99乘法表:

import xlwt

wb = xlwt.Workbook()
ws = wb.add_sheet('sheet1')
ws2 = wb.add_sheet('sheet2')

def write99():
        for i in range(1,10):
                for j in range(1,10):
                        ws.write(i-1,j-1,i*j)

write99()
wb.save('aca.xls')

相关内容

    暂无相关文章