Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Merge feat/spreadsheets

KnifeLemond00ee3494316
diff --cc Directory.Packages.props
index fa83795c,01236c82..c8e704fa
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@@ -34,10 -34,7 +34,11 @@@
<PackageVersion Include="Unhwp" Version="0.13.0" />
<PackageVersion Include="Markdig" Version="1.4.0" />
<PackageVersion Include="ExcelNumberFormat" Version="1.1.0" />
+ <!-- 5.2+ requires SkiaSharp 4 (see PDFtoImage above); 5.1.1 uses SkiaSharp 3.119 and HarfBuzzSharp 8.3 like Avalonia. -->
+ <PackageVersion Include="Svg.Skia" Version="5.1.1" />
+ <!-- Managed zstd / bzip2 for unpacking downloaded engines (conda packages). -->
+ <PackageVersion Include="SharpCompress" Version="1.0.0" />
+ <PackageVersion Include="ExcelDataReader" Version="3.9.0" />
</ItemGroup>
<ItemGroup Label="Tests">
diff --cc THIRD-PARTY-NOTICES.md
index eaac7a35,4a171cc9..269d2709
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@@ -23,9 -20,9 +23,10 @@@ Each component remains under its own li
| Unhwp | MIT | https://github.com/iyulab/unhwp |
| Markdig | BSD-2-Clause | https://github.com/xoofx/markdig |
| ExcelNumberFormat | MIT | https://github.com/andersnm/ExcelNumberFormat |
+ | ExcelDataReader | MIT | https://github.com/ExcelDataReader/ExcelDataReader |
| pypandoc-hwpx (Pandoc AST mapping and package layout in `Filee.Engines/Hwp/Hwpx`, incl. the `blank.hwpx` reference document) | MIT, Copyright (c) 2024 pypandoc-hwpx Contributors | https://github.com/msjang/pypandoc-hwpx |
| Microsoft.Extensions.* | MIT | https://github.com/dotnet/runtime |
+| cu2qu (fontTools): the cubic-to-quadratic approach followed by `Filee.Engines/Fonts/Cff/CubicToQuadratic.cs` | Apache-2.0, Copyright 2016 Google Inc. | https://github.com/fonttools/fonttools |
## Engines
diff --cc docs/ENGINES.md
index 77ea448f,91d077b7..dce0f27d
--- a/docs/ENGINES.md
+++ b/docs/ENGINES.md
@@@ -12,16 -10,13 +12,16 @@@ Filee chooses engines automatically. Se
| PDFium | built in (library) | PDF → images (multi-page TIFF/GIF supported) |
| Unhwp | built in (library) | HWP/HWPX → TXT, Markdown, HTML |
| Markdown (Markdig) | built in (library) | **Markdown → HTML, TXT** (and → PDF / DOCX through the HWPX writer, rhwp or LibreOffice) |
- | Spreadsheets | built in | **XLSX ↔ CSV** (one CSV per sheet) |
+ | Spreadsheets (ExcelDataReader for XLS) | built in (library) | **XLSX, XLS, ODS, CSV, TSV → XLSX, ODS, CSV, TSV** (one CSV / TSV per sheet) |
+| Fonts | built in | **TTF, OTF, WOFF, WOFF2, EOT ↔ each other**; CFF (PostScript) outlines become TrueType for TTF and EOT |
- | **HWPX writer** | built in | **DOCX, XLSX, CSV, PPTX, TXT, Markdown → HWPX** (and with rhwp → PDF and images); HTML, ODT, RTF → HWPX with Pandoc |
+ | **HWPX writer** | built in | **DOCX, XLSX, XLS, ODS, CSV, TSV, PPTX, TXT, Markdown → HWPX** (and with rhwp → PDF and images); HTML, ODT, RTF → HWPX with Pandoc |
| rhwp | bundled with the installer (`engines/rhwp`) | HWP/HWPX → PDF, **HWP → HWPX, HWPX → HWP** |
+| Archives (7-Zip) | bundled with the installer (`engines/7zip`, ~2.5 MB) + built-in readers | ZIP, 7Z, RAR, TAR (+ GZ/BZ2/XZ/Z/7Z/LZ), CAB, ISO, DMG, … **→ folder, ZIP, 7Z, TAR, TAR.GZ/BZ2/XZ**; ALZ, EGG, lzip read in-process; "Compress into one archive" for any files |
- | LibreOffice + H2Orestart + Java | **optional download** (~420 MB, 1.3 GB on disk) | older and rare formats only: DOC, XLS, PPT, RTF and OpenDocument → PDF and to each other, output as DOCX/ODT/ODS; HWP/HWPX → DOCX/ODT |
+ | LibreOffice + H2Orestart + Java | **optional download** (~420 MB, 1.3 GB on disk) | older and rare formats only: DOC, PPT, RTF, ODT and ODP → PDF and to each other, output as DOCX/ODT/XLS; HWP/HWPX → DOCX/ODT |
| Pandoc | **optional download** (~42 MB, 240 MB on disk) | Markdown ↔ DOCX/ODT/RTF, DOCX/ODT/HTML/RTF → Markdown, HTML ↔ DOCX/ODT |
+| Ghostscript | **optional download** (~20 MB, 31 MB on disk) | EPS/PS → PDF, PDF → EPS/PS, PostScript-based AI → PDF (images through PDF and PDFium) |
- DOCX, XLSX and PPTX → PDF need neither Microsoft Office nor LibreOffice: they are read in-process, written as HWPX
+ DOCX, XLSX, XLS, ODS and PPTX → PDF need neither Microsoft Office nor LibreOffice: they are read in-process, written as HWPX
and rendered by rhwp. LibreOffice's cost is set so the built-in route always wins where one exists.
Filee never uses software installed on the system (Microsoft Office, an installed LibreOffice, programs on `PATH`):
@@@ -122,36 -92,30 +122,60 @@@ text) and LibreOffice + H2Orestart (ope
Not converted: Word charts, SmartArt, equations (kept as text), free-form shapes, tracked changes and comments.
+ ## Spreadsheets
+
+ `SpreadsheetConverter` (engine id `spreadsheet`) converts between XLSX, XLS (also `.xlt`), ODS, CSV and TSV (also
+ `.tab`) in-process; every format goes through one in-memory workbook (`Office/Sheets/Workbook.cs`) whose cells keep
+ the text the spreadsheet shows, the value behind it and its Excel number format.
+
+ | Format | Read | Written |
+ |---|---|---|
+ | XLSX | own reader: values, number formats, fonts, fills, borders, alignment, merges, widths, heights, hidden rows / columns / sheets, frozen rows | every sheet, numbers and dates as numbers with their formats, booleans, styles, merges, widths, heights, hidden rows / columns, frozen rows |
+ | XLS (Excel 97–2003, also Excel 5/95) | ExcelDataReader (MIT): values, number formats, merges, horizontal / vertical alignment; widths, heights and hidden rows / columns from the BIFF records (`XlsLayout.cs`) | no (LibreOffice) |
+ | ODS | own reader (`content.xml`, `styles.xml`, `settings.xml`): repeated rows / columns (the empty repeats up to the end of the sheet are skipped), spans, every value type, the text Calc shows (`text:p`), data styles as Excel codes, cell styles, widths, heights, hidden rows / columns / sheets, frozen and header rows | every sheet, typed cells (float, percentage, currency, date, time, boolean) with data styles and the shown text, styles, merges, widths, heights, hidden rows / columns, frozen rows |
+ | CSV / TSV | delimiter (CSV: comma, semicolon or tab; TSV: tab) and encoding (UTF-8 / UTF-16 with BOM, else CP949) | UTF-8 with BOM, CRLF, one file per sheet |
+
+ - Number formats: Excel codes and OpenDocument data styles are converted both ways (`OdsNumberStyles.cs`) for
+ digits, decimals, grouping, thousands scaling, percent, scientific, currency symbols, literal text, colours,
+ positive / negative / zero sections, dates, times and durations. Codes with conditions (`[>100]`), fractions or
+ text between digits are written as plain numbers (General).
+ - Column widths use Excel's unit (a digit of Calibri 11 = 7 px); in ODS a character is 5.25 pt. LibreOffice
+ measures with its own fonts, so a width can differ by up to a fifth after LibreOffice opens the file.
+ - XLS cells keep the default font, fill and borders (ExcelDataReader does not expose them); XLS output still
+ needs LibreOffice. Password-protected XLS and ODS files stop with a clear message.
+ - Not converted: formulas (their cached results are kept), charts, pictures, comments, conditional formatting,
+ data validation, print areas and page breaks.
+
+## Fonts
+
+Fonts are converted in-process (`Filee.Engines/Fonts`); zlib and Brotli come with .NET. The input format is
+recognised by content, so a mislabelled file still converts.
+
+- **WOFF 1.0**: every table zlib-compressed (stored as-is when that isn't smaller). Lossless both ways.
+- **WOFF2**: one Brotli stream at the highest quality with the glyf/loca transform and, where it applies, the hmtx
+ transform, so files come out the size of Google's reference encoder's. Reading handles both transforms, the
+ overlap bitmap, untransformed tables and the first font of a WOFF2 collection. Like other encoders, Filee drops
+ the DSIG signature and sets bit 11 of head.flags. Brotli is slow on big fonts (about 10 s per MB, so about a
+ minute for a 4.6 MB CJK font); the job shows progress and can be cancelled.
+- **EOT**: written as version 0x00020001 (names and OS/2 fields in the header, no MicroType Express compression, no
+ XOR obfuscation, no URL restriction). Uncompressed EOT files are read (XOR-obfuscated ones too); MTX-compressed
+ ones fail with a clear message.
+- **TTF → OTF** keeps the TrueType outlines: TrueType-flavoured OpenType is valid OpenType and what systems and
+ browsers expect; cubic outlines would gain nothing.
+- **OTF with CFF outlines → TTF** (and → EOT, because Internet Explorer renders only TrueType outlines in EOT)
+ converts the glyphs: Type 2 charstrings with subroutines, flex, seac accents and CID-keyed fonts are drawn, curves
+ are approximated with quadratic splines within 1/1000 em (the approach of fontTools' cu2qu) and contours are
+ reversed to TrueType's direction. glyf, loca, maxp 1.0 and post (format 2 with the CFF glyph names, format 3 for
+ CID fonts) are built; head, hhea, hmtx and, from VORG, vmtx are updated; CFF, VORG and DSIG are dropped; every
+ other table (cmap, name, OS/2, GSUB, GPOS, kern, ...) is kept. PostScript hints are not converted: the font gets a
+ gasp table (smoothing at every size) and a prep that switches on dropout control instead.
+- Not supported: CFF2 (variable) outlines to TTF or EOT (to WOFF, WOFF2 and OTF they convert), writing font
+ collections, and WOFF/WOFF2 extended metadata (dropped).
+
+`tests/Filee.Engines.Tests/FontTests.cs` checks every conversion with small OFL fonts in
+`tests/Filee.Engines.Tests/Fonts` (see `OFL.txt` there): round trips keep every table byte for byte, a WOFF2 made
+by Google's encoder decodes to the source font, and converted CFF glyphs are compared with the originals in Skia.
+
## HWP ↔ HWPX
rhwp converts between the two 한글 formats without Hancom Office (`export-hwpx` and `convert`). Anything → HWP goes
diff --cc src/Filee.Engines/Filee.Engines.csproj
index ac5a6676,8d2cc57b..4bd407ab
--- a/src/Filee.Engines/Filee.Engines.csproj
+++ b/src/Filee.Engines/Filee.Engines.csproj
@@@ -18,8 -18,7 +18,9 @@@
<PackageReference Include="Unhwp" />
<PackageReference Include="Markdig" />
<PackageReference Include="ExcelNumberFormat" />
+ <PackageReference Include="Svg.Skia" />
+ <PackageReference Include="SharpCompress" />
+ <PackageReference Include="ExcelDataReader" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
</ItemGroup>
diff --cc src/Filee.Engines/Office/SpreadsheetConverter.cs
index 5ac30b6b,4add85c1..95688587
--- a/src/Filee.Engines/Office/SpreadsheetConverter.cs
+++ b/src/Filee.Engines/Office/SpreadsheetConverter.cs
@@@ -1,8 -1,8 +1,9 @@@
- // XLSX → CSV and CSV → XLSX without Excel or LibreOffice. XLSX / CSV → PDF, HWPX and HTML go through the HWPX
- // writer (sheets become 한글 tables), see HwpxConverter and SheetDocument.
+ // Spreadsheets between XLSX, XLS, ODS, CSV and TSV without Excel or LibreOffice (XLS and XLT are read, not written).
+ // XLSX / XLS / ODS / CSV / TSV → PDF, HWPX and HTML go through the HWPX writer (sheets become 한글 tables), see
+ // HwpxConverter and SheetDocument.
using Filee.Core.Conversion;
+using Filee.Engines.Infrastructure;
using Filee.Engines.Office.Sheets;
namespace Filee.Engines.Office;
@@@ -14,10 -17,10 +18,12 @@@ public sealed class SpreadsheetConverte
public string DisplayName => "Spreadsheets (built-in)";
public int MaxParallelism => 0;
- public IReadOnlyList<ConversionEdge> Edges { get; } = [new("xlsx", "csv"), new("csv", "xlsx")];
+ public IReadOnlyList<ConversionEdge> Edges { get; } =
+ [.. Sources.SelectMany(from => Targets.Where(to => to != from).Select(to => new ConversionEdge(from, to)))];
- public EngineStatus GetStatus() => EngineStatus.Available("XLSX, XLS, ODS, CSV, TSV → XLSX, ODS, CSV, TSV");
+ public EngineStatus GetStatus() =>
- EngineStatus.Available(version: $"{EngineVersions.BuiltIn} · {EngineVersions.Library("ExcelNumberFormat", typeof(ExcelNumberFormat.NumberFormat))}");
++ EngineStatus.Available("XLSX, XLS, ODS, CSV, TSV → XLSX, ODS, CSV, TSV",
++ $"{EngineVersions.BuiltIn} · {EngineVersions.Library("ExcelDataReader", typeof(ExcelDataReader.ExcelReaderFactory))}");
public Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken) =>
Task.Run<IReadOnlyList<string>>(() =>