'''
参考链接:
https://blog.csdn.net/grey_csdn/article/details/71436536
'''
import win32com.client
#打开加密的Excel文件
xlApp = win32com.client.Dispatch("Excel.Application")
filename,password = r"encryptedtest.xlsx", '123456'
xlwb = xlApp.Workbooks.Open(filename, False, True, None, Password=password)
#读取工作表的单元格A1
print(xlwb.Sheets(1).Cells(1,1))
#获取工作表行数
rsheet = xlwb.Worksheets(1) #1 代表第一张工作表
row_len = rsheet.Range('A65536').End(win32.constants.xlUp).Row
#将该工作簿另存为新文件
xlopen.SaveAs(new_filename)
#新建工作簿以及工作表,并写入数据
xlBook = xlApp.Workbooks.Add()
xlApp.Worksheets.Add().Name = 'test'
xlSheet = xlApp.Worksheets('test')
xlSheet.Cells(1,1).Value = 'title'
xlSheet.Cells(2,1).Value = 123
xlBook.SaveAs(pwd + '\\demo.xlsx')
xlApp.Quit()