Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODS file corrupts when I duplicate a sheet #13

Open
ItaloCunhaBueno opened this issue Oct 6, 2020 · 0 comments
Open

ODS file corrupts when I duplicate a sheet #13

ItaloCunhaBueno opened this issue Oct 6, 2020 · 0 comments

Comments

@ItaloCunhaBueno
Copy link

Here's my code example

import ezodf as ods


file = r'example_file.ods'
for x in range(2, 6):
    print(x)
    ODS = ods.opendoc(file)
    per1 = ODS.sheets['perimetro_1'] #the example file has a sheet called 'perimetro_1'
    duplicate = per1.copy(newname='perimetro_{0}'.format(x))
    ODS.sheets += duplicate
    ODS.save()

when trying to duplicate for the second time, this error occurs:

Traceback (most recent call last):
  File "e:\Trabalho\Repos\Geoja\Gra\SGT\teste.py", line 7, in <module>
    ODS = ods.opendoc(file)
  File "C:\Program Files\Python37\lib\site-packages\ezodf\document.py", line 54, in opendoc
    return PackagedDocument(filemanager=fm, mimetype=mime_type)
  File "C:\Program Files\Python37\lib\site-packages\ezodf\document.py", line 226, in __init__
    self.content = OfficeDocumentContent(mimetype, fm.get_xml_element('content.xml'))
  File "C:\Program Files\Python37\lib\site-packages\ezodf\filemanager.py", line 136, in get_xml_element
    return etree.XML(filecontent)
  File "src\lxml\etree.pyx", line 3216, in lxml.etree.XML
  File "src\lxml\parser.pxi", line 1896, in lxml.etree._parseMemoryDocument
  File "src\lxml\parser.pxi", line 1784, in lxml.etree._parseDoc
  File "src\lxml\parser.pxi", line 1141, in lxml.etree._BaseParser._parseDoc
  File "src\lxml\parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc
  File "src\lxml\parser.pxi", line 725, in lxml.etree._handleParseResult
  File "src\lxml\parser.pxi", line 654, in lxml.etree._raiseParseError
  File "<string>", line 2
lxml.etree.XMLSyntaxError: ID control9 already defined, line 2, column 1190729
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant