Python——office编程
一、office编程需求
二、Excel编程
1 import xlrd 2 path=input("输入路径:") 3 workbook=xlrd.open_workbook(path)#打开该Excel 4 sheet=workbook.sheet_by_index(1)#选择表单 5 for row in range(sheet.nrows):#遍历行,row行 6 print()#换行 7 for col in range(sheet.ncols): 8 print("%7s"%sheet.row(row)[col].value,'\t',end='')
1 import xlwt 2 # 创建一个workbook 设置编码 3 workbook = xlwt.Workbook(encoding = 'utf-8') 4 # 创建一个worksheet 5 worksheet = workbook.add_sheet('My Worksheet') 6 7 # 写入excel 8 # 参数对应 行, 列, 值 9 worksheet.write(1,0, label = 'this is test') 10 11 # 保存 12 workbook.save('Excel_test.xls')
三、word编程
四、PowerPoint编程