import xlwt import xlrd import xlutils from xlutils . copy import copy # f = xlwt . Workbook () # w = f . add_sheet ( "TestResult" , cell_overwrite_ok = True ) # w . write ( 0 , 0 , "Time" ) # w . write ( 0 , 1 , "Stock" ) # w . write ( 0 ,
import xlrd
import xlutils
from xlutils.copy import copy
# f=xlwt.Workbook()
# w=f.add_sheet("TestResult", cell_overwrite_ok=True)
# w.write(0,0,"Time")
# w.write(0,1,"Stock")
# w.write(0,2,"Bug")
# w.write(0,3,u"卖出")
# f.save(r"C:\Git\A.xls")
f=xlrd.open_workbook("A.xls")#读取一个Excel文件到内存
table=f.sheet_by_index(0)
d=xlutils.copy.copy(f)#复制表
w=d.get_sheet(0) #定位新的表 使用get_sheet方法
norows=table.nrows
print(norows)
d.save("A.xls")#保存到原来的数据中