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')
复制代码

 

posted @   dafengchui  阅读(2185)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示