語言:Python 3.7
學習時間:2天
適用工作:將excel另存為
參考文檔:https://pypi.org/project/xlutils/
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 9 17:18:33 2019
@author: zbliuA
"""
import xlrd
import time
from xlutils.copy import copy
file_path = ('F:\\Documents\\1生產計劃\\1生產計劃\\1排產\\201908\\最新發貨計劃.xlsx')
#讀取文件
read_file = xlrd.open_workbook(file_path)
#參數注釋:
#file_path:文件路徑,包含文件的全名稱
#formatting_info=True:保留Excel的原格式
#將文件復制到內存
write_data = copy(read_file)
#讀取復制后文件的sheet1
ws = write_data.get_sheet(0)
# 新工作簿writer覆蓋原工作簿work_book
write_data.save(r"F:\Documents\1生產計劃\1生產計劃\1排產\201908"+"\\"+time.strftime("%Y-%m-%d") + "發貨計劃.xls")