Skip to content

fix(libreoffice): fix CSV export crash and add LibreOffice Calc category - #567

Open
gingeekrishna wants to merge 4 commits into
C4illin:mainfrom
gingeekrishna:fix/libreoffice-csv-export-filter
Open

fix(libreoffice): fix CSV export crash and add LibreOffice Calc category#567
gingeekrishna wants to merge 4 commits into
C4illin:mainfrom
gingeekrishna:fix/libreoffice-csv-export-filter

Conversation

@gingeekrishna

@gingeekrishna gingeekrishna commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Closes #561.

Converting any document to CSV via LibreOffice fails with:

no export filter for <output>.csv found, aborting.

followed by an ENOENT because the output file was never written.

Root cause

getFilters() used a single shared filter map for both the --infilter (input) and --convert-to <format>:<filter> (output) arguments. The map contained:

csv: "Text",  // LibreOffice Writer filter

"Text" is a valid input filter for reading delimiter-separated files inside LibreOffice Writer, but it is not accepted as an output filter for the .csv extension — Writer simply has no CSV export filter. LibreOffice therefore aborts with the "no export filter found" error every time a Writer-category document (pdf, docx, odt, etc.) is converted to CSV.


Fix

1. Separate input and output filter maps

Replaced the single filters object with inputFilters and outputFilters. csv appears in inputFilters.text (Writer can open CSVs as plain text) but is absent from outputFilters.text (Writer cannot export CSV). getFilters() now looks up the right map for each side.

2. Remove csv from properties.to.text

The UI/router no longer offers any Writer-category to CSV path, since it is unsupported.

3. Add LibreOffice Calc category

filters.calc was present in the code but completely empty. This PR fills it with correct LibreOffice Calc filter names and adds from.calc / to.calc format lists, enabling spreadsheet conversions that were previously impossible:

From To Filter used
xlsx csv Calc MS Excel 2007 XMLText - txt - csv (StarCalc)
csv xlsx Text - txt - csv (StarCalc)Calc MS Excel 2007 XML
ods xlsx calc8Calc MS Excel 2007 XML
xls ods MS Excel 97calc8

All existing tests continue to pass. Four new tests cover the Calc path and the regression.


Summary by cubic

Fixes LibreOffice CSV export crashes by separating input and output filters and blocking unsupported Writer→CSV. Adds a Calc category with working filters for spreadsheet conversions and corrects the SYLK .slk mapping.

  • Split shared filters into inputFilters and outputFilters; getFilters() selects by direction.
  • Widen inputFilters values to string | null since Writer auto-detects Works (.wps) files (fix(libreoffice): don't force MS Word 97 infilter on .wps #585).
  • Remove csv from properties.to.text to stop offering Writer→CSV (e.g., pdf→csv).
  • Populate Calc filters and add properties.from.calc/properties.to.calc to enable xlsx↔csv, ods↔xlsx, and xls↔ods via Calc.
  • Map SYLK to .slk so .slk files match and use the SYLK infilter.
  • Add tests for Calc paths and the blocked Writer→CSV path; apply Prettier formatting.

Written for commit 431d19b. Summary will update on new commits.

Review in cubic

Copilot AI review requested due to automatic review settings June 21, 2026 11:20
@github-actions github-actions Bot added the Fix label Jun 21, 2026
@github-actions github-actions Bot added Fix and removed Fix labels Jun 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes LibreOffice CSV conversion failures by separating input vs output filter selection (preventing Writer→CSV export attempts) and adds a new LibreOffice Calc category to enable spreadsheet conversions with correct filters.

Changes:

  • Split the LibreOffice filter map into inputFilters and outputFilters, and updated getFilters() to select appropriately.
  • Removed unsupported Writer-category CSV output (csv) from properties.to.text so the UI/router no longer advertises invalid conversions.
  • Added Calc format lists + filter mappings and introduced new tests covering spreadsheet paths and the CSV regression.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/converters/libreoffice.ts Adds Calc format support; splits input/output filter maps; updates filter selection logic; updates supported format properties.
tests/converters/libreoffice.test.ts Adds regression + Calc-path tests validating the generated soffice CLI arguments.
Comments suppressed due to low confidence (1)

src/converters/libreoffice.ts:220

  • getFilters() uses the in operator to test membership in plain objects. Since fileType/convertTo ultimately come from user-controlled file extensions and request params, values like __proto__ will match via the prototype chain and can produce incorrect filter lookups (or [object Object] in CLI args). Use an own-property check instead of in.
  return [null, null];
};

export function convert(
  filePath: string,
  fileType: string,
  convertTo: string,
  targetPath: string,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/converters/libreoffice.ts
Comment thread src/converters/libreoffice.ts
@C4illin

C4illin commented Aug 19, 2026

Copy link
Copy Markdown
Owner

should be fixed by #609

…gory

LibreOffice Writer has no CSV export filter.  The shared filter map used
Text for csv in both directions, which made any Writer-category conversion
to csv fail with:

  no export filter for <file>.csv found, aborting.

Root cause: getFilters() looked up the same filters map for the infilter and
the outfilter.  Text is a valid *input* filter for reading delimiter-
separated files in Writer but is not accepted as an *output* filter for the
.csv extension.

Fix:
- Split into separate inputFilters / outputFilters maps so csv can remain
  readable by the text (Writer) category without offering it as a write
  target there.
- Remove csv from properties.to.text so the UI/router no longer exposes
  the unsupported Writer → CSV path.
- Populate the previously-empty filters.calc with correct LibreOffice Calc
  filter names and add spreadsheet formats to properties.from.calc /
  properties.to.calc, enabling conversions such as xlsx → csv, csv → xlsx,
  ods → xlsx, etc. via the Calc module.

Fixes C4illin#561

Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
The conventional file extension for SYLK spreadsheets is .slk, not .sylk.
Using sylk meant uploaded .slk files would never match the properties entry
and would not receive the SYLK infilter.

Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
Signed-off-by: Radhakrishnan P <gingeekrishna@gmail.com>
inputFilters.text.wps is null (LibreOffice auto-detects Works files;
see C4illin#585), but the Record<FileCategories, Record<string, string>>
annotation didn't allow it, so tsc failed with "Type 'null' is not
assignable to type 'string'". Widen the value type to string | null.

Signed-off-by: Radhakrishnan P <gingeekrishna@gmail.com>
@gingeekrishna
gingeekrishna force-pushed the fix/libreoffice-csv-export-filter branch from c02de53 to 431d19b Compare August 30, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert PDF to CSV error via LibreOffice

3 participants