Daniel please skip, Novice can refer to, see the following code comments,
Another problem, want to learn this language, the best English cow some, can go to the official website to see more useful library, Chinese information is not very full
1 #Run Environment 3.4, below this action Excel package is for Excel2007 and above version of the2 #import the necessary packages before you can manipulate Excel3 #Import Mode, cmd run: Pip install OPENPYXL4 fromOpenpyxlImportWorkbook5 6 #Create a new workbook7WB =Workbook ()8 9 #How to create a new worksheetTen #ws1 = Wb.create_sheet () One A #grab an active worksheet -WS =wb.active -ws.title="Test Cases" the - #write data directly into a cell -Xst'A1'] = 42 - + #add a row of data -Ws.append ([1, 2,"Hello, Pepe! "]) + A #Python can automatically type conversions at Importdatetime - -ws['A2'] =Datetime.datetime.now () - - #convenient operation of a variable cell -D = Ws.cell (row = 5, column = 5) inD.value="Hello, bye! " - toValue=D.value + Print("This is the data that is read out:", value) - the #Save the file *Wb.save (R"D:\test\sample.xlsx") $ Panax Notoginseng Print("Save complete! You can open it and watch it! ")
Use Python to read and write versions of Excel2007 and above, from the official demo