Excle的读取
# xlrd读取exlce的三方库
# 读取工作簿
# xlrd.open_workbook('文件地址')
# 读取工作表
# xlsx.sheet_by_name('表名') 或者 xlsx.sheet_by_index(表序号)
# 读取表格的第二行第三列的单元格内容
# print(table.cell_value(行, 列))
# print(table.cell(行, 列).value)
# print(table.row(行)[列].value)
import xlrd
xlsx = xlrd.open_workbook('F:/021Python自动化/7月下旬入库表.xlsx')
table = xlsx.sheet_by_name("7月下旬入库表")
# table = xlsx.sheet_by_index(0)
print(table.cell_value(1, 2))
print(table.cell(1, 2).value)
print(table.row(1)[2].value)
Excle的新建
# xlwt新建写入Excle的三方库
# 新建工作簿
# xlwt.Workbook()
# 新建工作表
# .add_sheet('工作表名称')
# 在单元格内写入内容
# .write(行, 列, '单元格内容')
# 保存工作簿
# .save('文件地址')
import xlwt
new_workbook = xlwt.Workbook()
worksheet = new_workbook.add_sheet('new sheet')
worksheet.write(0, 0, 'test')
new_workbook.save('D:/test.xls')
导入库和库的一个方法
from xlutils.copy imp