python 设置excel表单元格格式为文本格式


https://www.bbsmax.com/A/KE5QaVW35L/
import os
import shutil
import numpy as np
from tkinter import filedialog, Tk
from os import getcwd
from re import findall

import xlwt


if __name__ == '__main__':
    #book=xlwt.Workbook(encoding='utf-8',style_compression=0)
    #sheet=book.add_sheet('date',cell_overwrite_ok=True)
    #sheet.write(0,0,'1234')
    #sheet.write(1,1,'hihih')
    f = xlwt.Workbook(encoding='utf-8',style_compression=0)  # 创建workbook,其实是execl
    sheet1 = f.add_sheet('反馈', cell_overwrite_ok=True)

    style1 = xlwt.XFStyle()  # 设置单元格格式为文本
    style1.num_format_str = '@'
    for i in range(0, 500):
        for j in range(0, 30):
            sheet1.write(i, j, style=style1)
    f.save(r'E:\老人卡\XXXXX操作员.xlsx')

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM