使用python修改excel文档,保留文档原有的样式风格
import numpy as np
import openpyxl as pd
from datetime import datetime, time
from random import *
one = True
def read(sheet):
global one
for row in sheet:
for cell in row:
if isinstance(cell.value,time):
cell.value = time(8,randint(28,40)) if one else time(17,randint(30,59))
one = not one
table = pd.load_workbook('2022.4.xlsx')
sheet=table['2022.4']
read(sheet)
table.save('2022.4__1.xlsx')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)