0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Python】Excelのデータを別のブックにコピーする(単体)

Posted at

import openpyxl as px

#aというExcelをwbに関連づける
wb = px.load_workbook('Book1.xlsx')

#aシートを関連付け
ws = wb['Sheet1']

#bというExcelをwbに関連づける
wb2 = px.load_workbook('Book2.xlsx')

#bシートを関連付け
ws2 = wb2['Sheet1']

#コピー元をaシートの任意のセル
copy = ws.cell(row = 3, column =1).value

#コピー先のbブック、bシートにコピー元のデータを貼り付け
ws2.cell(row =2, column =1 , value = copy)

#bブックを「copy4」で保存する
wb2.save(filename = 'copy4.xlsx')

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?