Move a worksheet in a workbook using openpyxl or xl* or xlsxwriter?

1,207 views
Skip to first unread message

Xtian Simon

unread,
Jun 29, 2018, 10:52:21 PM6/29/18
to python-excel
I've read the docs for openpyxl, xlwt, xlrd, xlutils, xlswriter. I don't find a way to move a sheet in an Excel workbook. Tests added a worksheet to the ends.

Concretely, I have a calendar of sorts, ['JAN','FEB',...,'DEC'] and I need to replace months as the need arises.

How do you order the sheets in an Excel workbook if you don't move them?

(Only exampe I can find is on StackOverflow and uses win32com and Book.Worksheets.Add(After=Sheet); seems strange none of these modules would have this method.)

Mark L.

unread,
Jul 3, 2018, 4:17:56 AM7/3/18
to python-excel
This StackOverflow post says to use xlswriter, create a list of the worksheets, and sort the list:
Hope it helps.
Mark

Charlie Clark

unread,
Jul 3, 2018, 4:20:17 AM7/3/18
to python...@googlegroups.com
Am .07.2018, 03:17 Uhr, schrieb Mark L. <t.mark...@gmail.com>:

> This StackOverflow post says to use xlswriter, create a list of the
> worksheets, and sort the list:
> https://stackoverflow.com/questions/21118823/possible-to-alter-worksheet-order-in-xlsxwriter
> Hope it helps.

Not really for an existing workbook, you can only use openpyxl for that.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
Reply all
Reply to author
Forward
0 new messages