Initial xlxs support
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m25s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m25s
This commit is contained in:
parent
2648a5ae84
commit
709c13995c
5 changed files with 164 additions and 22 deletions
40
backend/test_xlsx.py
Normal file
40
backend/test_xlsx.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import zipfile
|
||||
|
||||
def create_empty_xlsx(filename):
|
||||
with zipfile.ZipFile(filename, 'w') as zf:
|
||||
# [Content_Types].xml
|
||||
zf.writestr('[Content_Types].xml', """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
||||
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
||||
<Default Extension="xml" ContentType="application/xml"/>
|
||||
<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>
|
||||
<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>
|
||||
</Types>""")
|
||||
|
||||
# _rels/.rels
|
||||
zf.writestr('_rels/.rels', """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
|
||||
</Relationships>""")
|
||||
|
||||
# xl/workbook.xml
|
||||
zf.writestr('xl/workbook.xml', """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
||||
<sheets>
|
||||
<sheet name="Sheet1" sheetId="1" r:id="rId1"/>
|
||||
</sheets>
|
||||
</workbook>""")
|
||||
|
||||
# xl/_rels/workbook.xml.rels
|
||||
zf.writestr('xl/_rels/workbook.xml.rels', """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
||||
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>
|
||||
</Relationships>""")
|
||||
|
||||
# xl/worksheets/sheet1.xml
|
||||
zf.writestr('xl/worksheets/sheet1.xml', """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
||||
<sheetData/>
|
||||
</worksheet>""")
|
||||
|
||||
create_empty_xlsx('test.xlsx')
|
||||
Reference in a new issue