import xlrd
import xlsxwriter
# work_book = xlrd.open_workbook("12010219801201332X王桂玉.xlsx")
# sheet_names = work_book.sheet_names()
# print(sheet_names)
# # sheet_content = work_book.sheet_names(sheet_names[0])
# sheet_content = work_book.sheet_by_name(sheet_names[0])
# print(sheet_content)
# nrows = sheet_content.nrows
# ncols = sheet_content.ncols
# print(nrows)
# print(ncols)
# for i in range(0,3):
# # for j in range(0,ncols):
# # print(sheet_content.row(i))
#
# # print(sheet_content.row(i)[0],end=' ')
# # print(sheet_content.row(i)[1],end=' ')
# # print(sheet_content.row(i)[2],end=' ')
# # print(sheet_content.row(i)[3],end=' ')
# # print(sheet_content.row(i)[4],end=' ')
# # print(sheet_content.row(i)[5],end=' ')
# # print(sheet_content.row(i)[6],end=' ')
# # print(sheet_content.row(i)[7],end=' ')
# # print(sheet_content.row(i)[8],end=' ')
# # print(sheet_content.row(i)[9],end=' ')
# # print(sheet_content.row(i)[10],end=' ')
#
# print(sheet_content.row_values(i))
# print(sheet_content.row(i))
# # print()
'''
['缴费单位', '缴费年月', '费款所属年月', '缴费基数', '单位划入统筹', '单位划入个人账户', '个人缴纳统筹', '个人缴纳金额', '缴费合计', '划入个人账户', '备注']
[text:'缴费单位', text:'缴费年月', text:'费款所属年月', text:'缴费基数', text:'单位划入统筹', text:'单位划入个人账户', text:'个人缴纳统筹', text:'个人缴纳金额', text:'缴费合计', text:'划入个人账户', text:'备注']
['渤海石油(临时1)', '200306', '200303', '2244', '381.48', '67.32', '0', '179.52', '628.32', '246.84', '']
[text:'渤海石油(临时1)', text:'200306', text:'200303', text:'2244', text:'381.48', text:'67.32', text:'0', text:'179.52', text:'628.32', text:'246.84', empty:'']
['渤海石油(临时1)', '200306', '200304', '2244', '381.48', '67.32', '0', '179.52', '628.32', '246.84', '']
[text:'渤海石油(临时1)', text:'200306', text:'200304', text:'2244', text:'381.48', text:'67.32', text:'0', text:'179.52', text:'628.32', text:'246.84', empty:'']
'''
'''
xlsxwriter写入excel .xlsx 格式,可以写入。不能追加
'''
namesec = "学生信息"+"2143242"+".xlsx"
# work_booksec = xlsxwriter.Workbook(namesec)
# sheetsec = work_booksec.add_worksheet("小明学生信息表")
# head = ['缴费单位', '缴费年月', '费款所属年月', '缴费基数', '单位划入统筹', '单位划入个人账户', '个人缴纳统筹', '个人缴纳金额', '缴费合计', '划入个人账户', '备注']
# data=[
# # [text:'缴费单位', text:'缴费年月', text:'费款所属年月', text:'缴费基数', text:'单位划入统筹', text:'单位划入个人账户', text:'个人缴纳统筹', text:'个人缴纳金额', text:'缴费合计', text:'划入个人账户', text:'备注'],
# ['渤海石油(临时1)', '200306', '200303', '2244', '381.48', '67.32', '0', '179.52', '628.32', '246.84', ''],
# # [text:'渤海石油(临时1)', text:'200306', text:'200303', text:'2244', text:'381.48', text:'67.32', text:'0', text:'179.52', text:'628.32', text:'246.84', empty:''],
# ['渤海石油(临时1)', '200306', '200304', '2244', '381.48', '67.32', '0', '179.52', '628.32', '246.84', ''],
# # [text:'渤海石油(临时1)', text:'200306', text:'200304', text:'2244', text:'381.48', text:'67.32', text:'0', text:'179.52', text:'628.32', text:'246.84', empty:''],
# ]
# for i in range(len(head)):
# sheetsec.write(0,i,head[i])
#
# for i in range(len(data)):
# for j in range(len(head)):
# sheetsec.write(i+1,j,data[i][j])
#
# work_booksec.close()
# namesec = "学生信息"+"2143242"+".xlsx"
namesec = "学生信息"+"2143242"+".xlsx"
info = [['渤海石油(临时1)', '20030226', '200303', '2244', '381.48', '67.32', '0', '179.52', '628.32', '246.84', ''],]
'''
openpyxl下标从1开始
'''
import openpyxl
import os
path = os.path.dirname(os.path.abspath(__file__))
print(path+'\'+namesec)
xfile = openpyxl.load_workbook(path+'\'+namesec)
sheetnames = xfile.sheetnames
print(sheetnames)
sheet1 = xfile.worksheets[0]
rows = sheet1.max_row
cols = sheet1.max_column
print(rows,cols)
print(len(info[0]))
for i in range(len(info[0])):
sheet1.cell(rows+1,i+1).value=info[0][i]
xfile.save(path+'\'+namesec)