jdum / odfdo

python library for OpenDocument format (ODF)
Apache License 2.0
58 stars 11 forks source link

Generating an spreadsheet, it has an extra empty sheet. #24

Closed pdenapo closed 1 year ago

pdenapo commented 1 year ago

I have created a test ods document using the following code:

from odfdo import Document, Table

body = doc.body
table = Table("Frequency Table")
table.set_values([[1,2],[2,3]])
body.append(table)

doc.save("hello.ods",pretty=True)

It has an empty extra empty sheet "Feuille 1" !

jdum commented 1 year ago

Yes, it has an empty sheet with default french name. Apparently you don't like French ? It is a feature that was requested years ago that a default empty .ods document was not absolutely empty, like expected by some libreoffice users.

A safe way to start on an empty document is clear():

doc = Document("spreadsheet") # missing line in your example doc.body.clear() # clear the body before append things.

(Other ways are possible)

If you struggle with odfdo for with numeric content in .ods files, you can try this tools based on odfdo: odsgenerator and odsparsator