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 CSV export crashes by separating input/output filters and removing the unsupported Writer→CSV path. Adds a Calc category with correct filters for spreadsheet conversions (xlsx↔csv, ods↔xlsx, xls↔ods) and corrects the SYLK (.slk) extension mapping.

  • Bug Fixes

    • Split filter map into inputFilters and outputFilters; getFilters() picks the right one.
    • Removed csv from properties.to.text to stop offering Writer→CSV.
    • Corrected SYLK extension to .slk so SLK files match and use the SYLK infilter.
    • Added tests for Calc paths and blocking Writer→CSV (e.g., pdf→csv).
  • Refactors

    • Applied Prettier formatting.

Written for commit cd913ff. Summary will update on new commits.

Review in cubic

…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>
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
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>

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
@github-actions github-actions Bot added Fix and removed Fix labels Jun 21, 2026
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>
@github-actions github-actions Bot added Fix and removed Fix labels Jun 27, 2026
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

2 participants