Merging worksheets from different xlsx files into a single workbook and saving

Issue #835 resolved
Paul Leopard created an issue

Given several XLSX files, each containing a single worksheet, is it possible to use OpenPYXL to copy the worksheets from these files and combine into a single workbook with the latest release? Googling found this code on stackoverflow but it complains that Workbook has no method named add_sheet. I assume that add_sheet has been removed. Is it possible to resurrect add_sheet for an upcoming release?

From :

from openpyxl import load_workbook, Workbook import os

fwb = Workbook()

wb = load_workbook('CM1.xlsx') ws1 = wb = load_workbook('CM2.xlsx') ws2 = wb = load_workbook('CM3.xlsx') ws3 =

fwb.add_sheet(ws1) fwb.add_sheet(ws2) fwb.add_sheet(ws3)'CM.xlsx')

Comments (3)

  1. CharlieC

    The problem is that worksheets are to a large degree dependent upon some global values of their parent workbooks such as styles and this makes merging more than a little tricky so that I currently do not anticipate providing this feature.

    As long as you only want the values then this is trivial to do in your own code.

  2. Log in to comment