How to Automate an Excel Sheet in Python? All You Need to Know

44 How to Automate an Excel Sheet in Python? All You Need to Know のメモ

  1. How to Add Row and Column での、セルの自動データ生成
    import openpyxl
    from openpyxl import Workbook, load_workbook
    
    wb = load_workbook('/content/Simplilearn.xlsx')
    ws = wb.active
    for i in range(1,11):
      ws.cell(row=i,column=1).value=i
      ws.cell(row=i,column=2).value=chr(ord('A')+i-1)
    
    ws.insert_rows(2)
    ws.insert_cols(1)
    wb.save('/content/Simplilearn.xlsx')    
    
  2. How to Perform Addition, Average, Product and Count in Excel Using Python での、セルの自動データ生成
    ws= wb.active
    for i in range(1,10):
      ws['B'+str(i)]=i
    

坂本直志 <sakamoto@c.dendai.ac.jp>
東京電機大学工学部情報通信工学科