import pyrfc, json import tablib from datetime import datetime import win32com.client, os, shutil, time xl = win32com.client.Dispatch("Excel.Application") file = r'D:\code\maria_po_transfer\t2\dn_template.xls' xl.DisplayAlerts = False xl.Visible = True wb = xl.Workbooks.Open(file) sheets = wb.Worksheets('P1') sheets.Rows('1:46').Copy() sheets.Rows('139:139').Select() sheets.Paste() sheets.Rows('159:159').Select() sheets.Paste() # 这些是VBA录屏代码 # Rows("1:1").Select # # Rows("1:46").Select # Selection.Copy # # Rows("139:139").Select # ActiveSheet.Paste
参考
https://github.com/pythonexcels/examples
https://pythonexcels.com/python/2009/10/12/mapping-excel-vb-macros-to-python
https://pythonexcels.com/python/2009/10/05/python-excel-mini-cookbook