3

I am doing my first steps with xlswriter.

I have an existing workbook test.xlsx, and I want to add to it a new worksheet - sheet 2.

what I tried is the following:

import xlsxwriter as xl
xbook=xl.Workbook('test.xlsx')
xbook.add_worksheet('sheet2')

The problem with this is that it overrides all the other sheets in the workbook. How can I add a worksheet without overriding all the other worksheets in the workbook?

Binyamin Even
  • 3,318
  • 1
  • 18
  • 45
  • Hey you can use [**openpyxl**](https://openpyxl.readthedocs.org/en/2.3.3/tutorial.html#create-a-workbook) for that and of course it works perfectly with **.xlsx** files – Tanmaya Meher Feb 11 '16 at 13:17
  • Can you explain how? I tried: `from openpyxl import load_workbook \n wb=load_workbook('test.xlsx') \n ws=wb.create_sheet() \n ws.title="sheet 2"` but the sheet was not created! – Binyamin Even Feb 11 '16 at 13:22

1 Answers1

3

I don't think this is still possible with xlsxwriter. Please take a look at this answer for help

Community
  • 1
  • 1
Obsidian
  • 515
  • 3
  • 10