zoukankan      html  css  js  c++  java
  • python excle写数据

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # @Time    : 2019/4/24 10:30
    # @File    : Excle写.py
    # @Software: PyCharm
    
    import xlwt
    
    #创建workbook和sheet对象
    workbook = xlwt.Workbook() #注意Workbook的开头W要大写
    sheet1 = workbook.add_sheet('sheet1',cell_overwrite_ok=True)
    sheet2 = workbook.add_sheet('sheet2',cell_overwrite_ok=True)
    
    #向sheet页中写入数据
    sheet1.write(0,0,'this should overwrite1')
    sheet1.write(0,1,'aaaaaaaaaaaa')
    sheet2.write(0,0,'this should overwrite2')
    sheet2.write(1,2,'bbbbbbbbbbbbb')
    
    """
    #-----------使用样式-----------------------------------
    #初始化样式
    style = xlwt.XFStyle() 
    #为样式创建字体
    font = xlwt.Font()
    font.name = 'Times New Roman'
    font.bold = True
    #设置样式的字体
    style.font = font
    #使用样式
    sheet.write(0,1,'some bold Times text',style)
    """
    
    #保存该excel文件,有同名文件时直接覆盖
    workbook.save(r'C:Users6396000951Desktop	est2工作表.xls')
    print('创建excel文件完成!')
    被狗吃掉的那几年
  • 相关阅读:
    IOS归档操作
    IOS文件操作
    NSNumber,NSValue,NSData
    dbcp数据库连接池属性介绍
    Spring整合hibernate4:事务管理
    Spring整合hibernate4
    Spring AOP
    Chapter 27 Controlling Animations
    Chapter 23 Core Data
    Chapter 21 WebServices and UIWebView
  • 原文地址:https://www.cnblogs.com/wangdecheng/p/10760849.html
Copyright © 2011-2022 走看看