delete a sheet

1,026 views
Skip to first unread message

JKos

unread,
Aug 18, 2010, 8:25:39 AM8/18/10
to python-excel
Can I delete a sheet from excel workbook?

I do:
inBook= xlrd.open_workbook(file)
outBook = xltuils.copy.copy(inBook)

I'm missing something similar too:
outBook.delete_sheet('sheet_name' or index)

I've found this thread:
http://groups.google.com.au/group/python-excel/browse_thread/thread/30e514f158f6fad6/94cda46fdc18ed6a?lnk=gst&q=delete+sheet#94cda46fdc18ed6a

but I can't find the appropriate functions in xlwt/rd.

Should one copy sheet by sheet from inBook and simply avoid the sheet
one wants to delete?

Thanks in advance!

BR

Chris Withers

unread,
Aug 18, 2010, 12:13:37 PM8/18/10
to python...@googlegroups.com
JKos wrote:
> Should one copy sheet by sheet from inBook and simply avoid the sheet
> one wants to delete?

Yes, xlutils.filter is your friend. Read the tutorial.

Chris

nick m

unread,
Jun 30, 2016, 12:42:20 AM6/30/16
to python-excel
I read the tutorial and I don't see anything on deleting sheets? Is it possible to delete sheets with xlrd, xlwt, xlutils, xlutils.filter or any combination of those?

Adrian Klaver

unread,
Jun 30, 2016, 10:04:42 AM6/30/16
to python...@googlegroups.com
On 06/29/2016 09:09 PM, nick m wrote:
> I read the tutorial and I don't see anything on deleting sheets? Is it
> possible to delete sheets with xlrd, xlwt, xlutils, xlutils.filter or
> any combination of those?

See here:
http://xlutils.readthedocs.io/en/latest/filter.html#filters

So
I would say in the def sheet method put in an 'if' that passes on the
sheet you do not want to write out.

See below for full example:

http://xlutils.readthedocs.io/en/latest/filter.html#example-usage

>
> On Wednesday, August 18, 2010 at 12:13:37 PM UTC-4, Chris Withers wrote:
>
> JKos wrote:
> > Should one copy sheet by sheet from inBook and simply avoid the sheet
> > one wants to delete?
>
> Yes, xlutils.filter is your friend. Read the tutorial.
>
> Chris
>
> --
> You received this message because you are subscribed to the Google
> Groups "python-excel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to python-excel...@googlegroups.com
> <mailto:python-excel...@googlegroups.com>.
> To post to this group, send email to python...@googlegroups.com
> <mailto:python...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/python-excel.
> For more options, visit https://groups.google.com/d/optout.


--
Adrian Klaver
adrian...@aklaver.com

Chris Withers

unread,
Jul 3, 2016, 3:04:45 PM7/3/16
to python...@googlegroups.com

As I said: yes, xlutils.filter is your friend. Just filter out sheets that you don't want.

--
You received this message because you are subscribed to the Google Groups "python-excel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-excel...@googlegroups.com.
To post to this group, send email to python...@googlegroups.com.
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Reply all
Reply to author
Forward
0 new messages