首页 > 编程语言 > 详细

python操作Excel

时间:2019-02-20 17:37:33      阅读:160      评论:0      收藏:0      [点我收藏+]
def write_excel():
    f = xlwt.Workbook()
    sheet1 = f.add_sheet(usheet1, cell_overwrite_ok=True)
    row0 = [u业务, u状态, u北京, u上海, u广州, u深圳, u状态小计, u合计]
    column0 = [u机票, u船票, u火车票, u汽车票, u其他]
    status = [u预订, u出票, u退票, u业务小计]

    for i in range(0, len(row0)):
        sheet1.write(0, i, row0[i], set_style(Times New Roman, 220, True))

    i, j = 1, 0
    while i < 4 * len(column0) and j < len(column0):
        sheet1.write_merge(i, i + 3, 0, 0, column0[j], set_style(Times New Roman, 220, True))
        sheet1.write_merge(i, i + 3, 7, 7)
        i += 4
        j += 1

    sheet1.write_merge(21, 21, 0, 1, u合计, set_style(Times New Roman, 220, True))

    i = 0
    while i < 4 * len(column0):
        for j in range(0, len(status)):
            sheet1.write(j + i + 1, status[j])
        i += 4

    f.save(demo.xlsx)


if __name__ == __main__:
    write_excel()

 

python操作Excel

原文:https://www.cnblogs.com/yellowhat/p/10407891.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!