Skip to content

Commit

Permalink
fix: generate ODS file more compatible with MS-Office365
Browse files Browse the repository at this point in the history
otherwise it opens in readonly mode with "repaired" warning
  • Loading branch information
prigaux committed Nov 18, 2024
1 parent 3547263 commit c37de36
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/src/services/spreadsheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ async function export_spreadsheet_raw(table_rows: string) {
`<?xml version="1.0" encoding="UTF-8"?>
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
<manifest:file-entry manifest:full-path="/" manifest:media-type="${mimetype}"/>
<manifest:file-entry manifest:full-path="styles.xml" manifest:media-type="text/xml"/>
<manifest:file-entry manifest:full-path="content.xml" manifest:media-type="text/xml"/>
</manifest:manifest>
`),
"styles.xml": fflate.strToU8(
`<?xml version="1.0" encoding="UTF-8"?>
<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" />
`),
"content.xml": fflate.strToU8(
`<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -43,8 +48,8 @@ async function export_spreadsheet_raw(table_rows: string) {
</office:automatic-styles>
<office:body>
<office:spreadsheet>
<table:table>
<table:table-column /> <!-- needed for schema compliance -->
<table:table table:name="Feuille1"> <!-- "name" needed for MS-Office365 -->
<table:table-column /> <!-- needed for schema compliance (??) -->
${table_rows}
</table:table>
</office:spreadsheet>
Expand All @@ -60,7 +65,7 @@ ${table_rows}

export async function to_ods(l: V[], attrs: StepAttrsOption) {
const format_table_cell_header = txt => (
` <table:table-cell table:style-name="mytitle"><text:p>${escapeXml(txt)}</text:p></table:table-cell>`
` <table:table-cell office:value-type="string" office:string-value="${escapeXml(txt)}" table:style-name="mytitle" />`
)
const format_table_cell = cell => (
typeof cell === 'number' ?
Expand Down

0 comments on commit c37de36

Please sign in to comment.