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.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
PDF -> XLSX: each ruled table on its own sheet (#267)
cre8ive-marketingfd19e4b80b01
diff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex 616f8222..ae2c1b16 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -20,6 +20,7 @@ Filee chooses engines automatically. Settings → *Engines* shows their status,| **DOCX writer** | built in | **HWPX (and HWP through rhwp), PDF, OFD, HTML, MHTML, EPUB, MOBI/AZW3, FB2, Markdown, TXT, XLSX, XLS, ODS, CSV, PPTX (+ variants) → DOCX** || PDF text | built in (PdfPig) | **PDF → TXT, Markdown** (reading order, also two columns; Markdown keeps headings, emphasis, links and the pictures; no OCR) || PDF slides | built in (PDFium, PdfPig) | **PDF → PPTX**: a picture of each page on its own slide (looks like the PDF, not editable), the page's text in the speaker notes |+| PDF tables | built in (PdfPig) | **PDF → XLSX** (#267): each table drawn with lines on its own sheet, numbers and dates as real values, merged cells and column widths kept || E-mail | built in (MimeKit, MsgReader) | **EML, Outlook MSG → HTML** (headers + body, inline pictures), **TXT**, **ZIP** (the attachments); **MSG → EML**; **MHTML → HTML** (the saved page in one file, pictures inlined; on to PDF, DOCX, HWPX, TXT, Markdown, EPUB from there) || Data | built in (System.Text.Json, YamlDotNet, Tomlyn, System.Xml) | **JSON, JSON Lines, YAML, TOML, XML, CSV ↔ each other** (CSV for tables); **vCard, iCalendar ↔ CSV**; spreadsheets, contacts and events reach JSON / YAML / TOML / XML through CSV || **E-books** | built in | **EPUB, MOBI/AZW/AZW3/PRC, FB2, HTMLZ, TXTZ → EPUB, HWPX (→ PDF), TXT, HTML, Markdown, FB2, HTMLZ, TXTZ**; HTML, Markdown, TXT, DOCX → EPUB/FB2/HTMLZ/TXTZ; HTML → TXT; comics CBZ/CBR/CB7/CBT/CBC → PDF, EPUB, CBZ; PDF → CBZ; AZW4 → PDF; **EPUB ↔ KEPUB** (Kobo) |@@ -635,6 +636,26 @@ differently inside an exact line (Word and LibreOffice at its foot, 한글 and rtext sits up to 0.2 sizes higher than on the page. LibreOffice adds cell borders to row heights: the DOCX of afull 140 mm invoice opened there puts its last line on a second page (rhwp's PDF keeps it on one).+## PDF → XLSX++`Pdf/PdfTablesConverter.cs` puts the tables of a PDF into a workbook (#267). The tables are the ruled ones PDF → DOCX+finds (`PdfDocumentReader.Tables.cs`, above): drawn with lines, with their merged cells, column widths and row+heights. Text outside the tables is left out, as the XLSX preset's hint says; tables aligned by white space only are+not found.++- **One sheet per table** ("Table 1", "Table 2" …). A table that goes on at the top of the next page with the same+ columns (widths within 5 %), right after one that ended its page, joins it on one sheet; a header row repeated on+ the new page is left out.+- **Numbers and dates** become real values with a number format that shows them as the PDF did: `1,234.50`+ (`#,##0.00`), `(120)` (negative), `$9.99` / `€1,000.00` / `₩` `£` `¥` `₹` (the symbol in the format), `12.5%`+ (`0.0%`), and dates with the year first, `2026-10-23`, `2026/1/5`, `2026. 10. 23.` (Korean style). Everything else+ stays text: a leading zero (codes, phone numbers), more than 15 digits, a decimal comma (`1.234,50`, which can't be+ told from thousands), day- or month-first dates.+- Every cell gets thin borders (the table was drawn with lines), its shading, vertical alignment and bold when all+ its text is bold; text wraps. Merged areas keep their borders on every covered cell.+- A PDF with no such table, or a scan (no text), fails with `error.pdf_no_tables` instead of writing an empty+ workbook. Through XLSX, the tables reach ODS and CSV too.+## PDF → PPTX`Pdf/PdfSlidesConverter.cs` turns a PDF into a PowerPoint deck of pictures: every page is rendered (PDFium, as fordiff --git a/src/Filee.App/Assets/i18n/ar.json b/src/Filee.App/Assets/i18n/ar.jsonindex 3f767640..b646342d 100644--- a/src/Filee.App/Assets/i18n/ar.json+++ b/src/Filee.App/Assets/i18n/ar.json@@ -90,6 +90,7 @@"error.needs_shaping": "يحتاج هذا النص إلى LibreOffice لتحويله بصورة صحيحة. ثبّته من الإعدادات ← المحركات","error.runtime_missing": "أحد ملفات وقت تشغيل Microsoft Visual C++ التي يحتاجها هذا المحرك مفقود أو قديم. حدّث Filee أو أعد تثبيته، أو ثبّت Microsoft Visual C++ Redistributable (x64)","error.conversion_failed": "أبلغ المحرك عن خطأ",+ "error.pdf_no_tables": "لا يحتوي ملف PDF هذا على جداول مرسومة بخطوط، فلا يوجد ما يوضع في جدول بيانات. ملف PDF الممسوح ضوئيًا لا يحتوي على نص أصلًا.","error.web_download_failed": "تعذّر تنزيل الملف","error.web_page": "يفتح الرابط صفحة ويب وليس ملفًا. لا يستطيع Filee تنزيل ملف يتطلب تسجيل الدخول: احفظه من المتصفح أولًا","error.web_too_large": "حجم الملف أكبر من 2 غيغابايت",@@ -522,6 +523,7 @@"presets.page_range": "الصفحات","presets.page_range_hint": "كل الصفحات، أو مثلًا 1-3, 5","presets.split": "ملف لكل صفحة",+ "presets.pdf_tables_note": "من ملف PDF يصبح كل جدول مرسوم بخطوط ورقة مستقلة (ويبقى الجدول الممتد إلى الصفحة التالية ورقة واحدة)، وتصبح الأرقام والتواريخ قيمًا حقيقية. يُترك النص خارج الجداول.","presets.pdf_compression": "الضغط","presets.pdf_compression.None": "دون ضغط","presets.pdf_compression.Screen": "أصغر حجم (الصور بدقة 72 dpi)",diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex 74117899..52b44600 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -96,6 +96,7 @@"error.needs_shaping": "This script needs LibreOffice to convert correctly. Install it in Settings → Engines","error.runtime_missing": "A Microsoft Visual C++ runtime file this engine needs is missing or outdated. Update or reinstall Filee, or install the Microsoft Visual C++ Redistributable (x64)","error.conversion_failed": "The engine reported an error",+ "error.pdf_no_tables": "This PDF has no tables drawn with lines, so there is nothing to put in a spreadsheet. A scanned PDF has no text at all.","error.web_download_failed": "Couldn't download the file","error.web_page": "The link opens a web page, not a file. Filee can't download a file that needs you to sign in: save it from the browser first","error.web_too_large": "The file is larger than 2 GB",@@ -537,6 +538,7 @@"presets.page_range": "Pages","presets.page_range_hint": "All pages, or e.g. 1-3, 5","presets.split": "One file per page",+ "presets.pdf_tables_note": "From a PDF, each table drawn with lines becomes its own sheet (a table that goes on over the next page stays one sheet), with numbers and dates as real values. Text outside the tables is left out.","presets.pdf_compression": "Compress","presets.pdf_compression.None": "Don't compress","presets.pdf_compression.Screen": "Smallest (pictures at 72 dpi)",diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.jsonindex a0d05417..f2e13cdf 100644--- a/src/Filee.App/Assets/i18n/es.json+++ b/src/Filee.App/Assets/i18n/es.json@@ -90,6 +90,7 @@"error.needs_shaping": "Este sistema de escritura necesita LibreOffice para convertirse bien. Instálalo en Ajustes → Motores","error.runtime_missing": "Falta un archivo del runtime de Microsoft Visual C++ que necesita este motor, o está desactualizado. Actualiza o reinstala Filee, o instala Microsoft Visual C++ Redistributable (x64)","error.conversion_failed": "El motor devolvió un error",+ "error.pdf_no_tables": "Este PDF no tiene tablas dibujadas con líneas, así que no hay nada que poner en una hoja de cálculo. Un PDF escaneado no tiene texto.","error.web_download_failed": "No se pudo descargar el archivo","error.web_page": "El enlace abre una página web, no un archivo. Filee no puede descargar un archivo que requiere iniciar sesión: guárdalo primero desde el navegador","error.web_too_large": "El archivo supera los 2 GB",@@ -522,6 +523,7 @@"presets.page_range": "Páginas","presets.page_range_hint": "Todas las páginas o, por ejemplo, 1-3, 5","presets.split": "Un archivo por página",+ "presets.pdf_tables_note": "De un PDF, cada tabla dibujada con líneas pasa a su propia hoja (una tabla que sigue en la página siguiente queda en una sola hoja), con números y fechas como valores reales. El texto fuera de las tablas se omite.","presets.pdf_compression": "Comprimir","presets.pdf_compression.None": "No comprimir","presets.pdf_compression.Screen": "El más pequeño (imágenes a 72 ppp)",diff --git a/src/Filee.App/Assets/i18n/fr.json b/src/Filee.App/Assets/i18n/fr.jsonindex 078bceb2..ef374a30 100644--- a/src/Filee.App/Assets/i18n/fr.json+++ b/src/Filee.App/Assets/i18n/fr.json@@ -96,6 +96,7 @@"error.needs_shaping": "Cette écriture nécessite LibreOffice pour être convertie correctement. Installez-le dans Paramètres → Moteurs","error.runtime_missing": "Un fichier du runtime Microsoft Visual C++ requis par ce moteur est manquant ou obsolète. Mettez à jour ou réinstallez Filee, ou installez Microsoft Visual C++ Redistributable (x64)","error.conversion_failed": "Le moteur a signalé une erreur",+ "error.pdf_no_tables": "Ce PDF n'a pas de tableau tracé avec des lignes : il n'y a rien à mettre dans un classeur. Un PDF numérisé n'a pas de texte du tout.","error.web_download_failed": "Impossible de télécharger le fichier","error.web_page": "Le lien ouvre une page web, pas un fichier. Filee ne peut pas télécharger un fichier qui exige une connexion : enregistrez-le d'abord depuis le navigateur","error.web_too_large": "Le fichier dépasse 2 Go",@@ -537,6 +538,7 @@"presets.page_range": "Pages","presets.page_range_hint": "Toutes les pages, ou par ex. 1-3, 5","presets.split": "Un fichier par page",+ "presets.pdf_tables_note": "D'un PDF, chaque tableau tracé avec des lignes devient une feuille (un tableau qui continue sur la page suivante reste une seule feuille), avec les nombres et les dates en vraies valeurs. Le texte hors des tableaux est omis.","presets.pdf_compression": "Compresser","presets.pdf_compression.None": "Ne pas compresser","presets.pdf_compression.Screen": "Le plus léger (images à 72 ppp)",diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.jsonindex 7c4e0678..8235f76c 100644--- a/src/Filee.App/Assets/i18n/hi.json+++ b/src/Filee.App/Assets/i18n/hi.json@@ -90,6 +90,7 @@"error.needs_shaping": "इस लिपि को सही ढंग से कन्वर्ट करने के लिए LibreOffice चाहिए। इसे सेटिंग्स → इंजन में इंस्टॉल करें","error.runtime_missing": "इस इंजन के लिए ज़रूरी Microsoft Visual C++ रनटाइम फ़ाइल नहीं मिली या पुरानी है। Filee को अपडेट करें या फिर से इंस्टॉल करें, या Microsoft Visual C++ Redistributable (x64) इंस्टॉल करें","error.conversion_failed": "इंजन ने एक त्रुटि बताई",+ "error.pdf_no_tables": "इस PDF में रेखाओं से बनी कोई तालिका नहीं है, इसलिए स्प्रेडशीट में डालने को कुछ नहीं है। स्कैन किए गए PDF में कोई टेक्स्ट नहीं होता।","error.web_download_failed": "फ़ाइल डाउनलोड नहीं हो सकी","error.web_page": "यह लिंक फ़ाइल नहीं, एक वेब पेज खोलता है। जिस फ़ाइल के लिए साइन-इन ज़रूरी है उसे Filee डाउनलोड नहीं कर सकता: पहले उसे ब्राउज़र से सेव करें","error.web_too_large": "फ़ाइल 2 GB से बड़ी है",@@ -522,6 +523,7 @@"presets.page_range": "पेज","presets.page_range_hint": "सभी पेज, या जैसे 1-3, 5","presets.split": "प्रति पेज एक फ़ाइल",+ "presets.pdf_tables_note": "PDF से, रेखाओं से बनी हर तालिका अपनी अलग शीट बनती है (अगले पेज पर जारी तालिका एक ही शीट रहती है), और संख्याएँ व तारीखें असली मान बनती हैं। तालिकाओं के बाहर का टेक्स्ट छोड़ दिया जाता है।","presets.pdf_compression": "कंप्रेस करें","presets.pdf_compression.None": "कंप्रेस न करें","presets.pdf_compression.Screen": "सबसे छोटा (तस्वीरें 72 dpi पर)",diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.jsonindex 287df55c..fe86da36 100644--- a/src/Filee.App/Assets/i18n/ja.json+++ b/src/Filee.App/Assets/i18n/ja.json@@ -90,6 +90,7 @@"error.needs_shaping": "この文字体系の文書を正しく変換するにはLibreOfficeが必要です。「設定」→「変換エンジン」でインストールしてください","error.runtime_missing": "このエンジンに必要なMicrosoft Visual C++ランタイムのファイルがないか、古くなっています。Filee を更新または再インストールするか、Microsoft Visual C++ 再頒布可能パッケージ(x64)をインストールしてください","error.conversion_failed": "変換エンジンからエラーが報告されました",+ "error.pdf_no_tables": "この PDF には罫線で描かれた表がないため、スプレッドシートにするものがありません。スキャンした PDF にはテキストがありません。","error.web_download_failed": "ファイルをダウンロードできませんでした","error.web_page": "リンク先はファイルではなくWebページです。ログインが必要なファイルは Filee ではダウンロードできないため、先にブラウザーで保存してください","error.web_too_large": "ファイルが2 GBを超えています",@@ -522,6 +523,7 @@"presets.page_range": "ページ","presets.page_range_hint": "全ページ、または1-3, 5など","presets.split": "1ページずつ別ファイルにする",+ "presets.pdf_tables_note": "PDF からは、罫線で描かれた表が 1 つずつシートになり(次のページに続く表は 1 つのシートのまま)、数値と日付は実際の値になります。表の外のテキストは含めません。","presets.pdf_compression": "圧縮","presets.pdf_compression.None": "圧縮しない","presets.pdf_compression.Screen": "最小サイズ(画像72 dpi)",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex 519bc2f7..2a117464 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -96,6 +96,7 @@"error.needs_shaping": "이 문자는 LibreOffice가 있어야 제대로 변환돼요. 설정 → 변환 엔진에서 설치해 주세요","error.runtime_missing": "이 엔진에 필요한 Microsoft Visual C++ 런타임 파일이 없거나 오래됐어요. Filee를 업데이트하거나 다시 설치하거나, Microsoft Visual C++ 재배포 가능 패키지(x64)를 설치해 주세요","error.conversion_failed": "엔진에서 오류가 발생했어요",+ "error.pdf_no_tables": "이 PDF에는 선으로 그린 표가 없어 스프레드시트에 넣을 내용이 없습니다. 스캔한 PDF에는 텍스트가 전혀 없습니다.","error.web_download_failed": "파일을 내려받지 못했어요","error.web_page": "링크가 파일이 아니라 웹페이지로 열려요. 로그인이 필요한 파일은 Filee가 내려받을 수 없으니 브라우저에서 먼저 저장해 주세요","error.web_too_large": "2GB보다 큰 파일이에요",@@ -537,6 +538,7 @@"presets.page_range": "페이지","presets.page_range_hint": "전체, 또는 예: 1-3, 5","presets.split": "페이지마다 파일 하나",+ "presets.pdf_tables_note": "PDF에서는 선으로 그린 표가 하나씩 시트가 되고(다음 페이지로 이어지는 표는 한 시트로 유지), 숫자와 날짜는 실제 값이 됩니다. 표 밖의 텍스트는 빠집니다.","presets.pdf_compression": "압축","presets.pdf_compression.None": "압축 안 함","presets.pdf_compression.Screen": "가장 작게 (이미지 72 dpi)",diff --git a/src/Filee.App/Assets/i18n/ne.json b/src/Filee.App/Assets/i18n/ne.jsonindex a5c27c21..fc905f3e 100644--- a/src/Filee.App/Assets/i18n/ne.json+++ b/src/Filee.App/Assets/i18n/ne.json@@ -90,6 +90,7 @@"error.needs_shaping": "यस लिपिलाई सही रूपमा रूपान्तरण गर्न LibreOffice आवश्यक पर्दछ। यसलाई सेटिङहरू → इन्जिनहरूमा स्थापना गर्नुहोस्","error.runtime_missing": "यो इन्जिनलाई आवश्यक पर्ने Microsoft Visual C++ रनटाइम फाइल फेला परेन वा पुरानो भयो। Filee लाई अपडेट वा पुन: स्थापना गर्नुहोस्, वा Microsoft Visual C++ Redistributable (x64) स्थापना गर्नुहोस्","error.conversion_failed": "इन्जिनले त्रुटि रिपोर्ट गर्यो",+ "error.pdf_no_tables": "यो PDF मा रेखाले बनाइएको तालिका छैन, त्यसैले स्प्रेडसिटमा राख्ने केही छैन। स्क्यान गरिएको PDF मा पाठ नै हुँदैन।","error.web_download_failed": "फाइल डाउनलोड गर्न सकिएन","error.web_page": "लिङ्कले फाइल नभई वेब पृष्ठ खोल्छ। साइन-इन आवश्यक पर्ने फाइल Filee ले डाउनलोड गर्न सक्दैन: पहिले यसलाई ब्राउजरबाट सुरक्षित गर्नुहोस्","error.web_too_large": "फाइल २ GB भन्दा ठूलो छ",@@ -522,6 +523,7 @@"presets.page_range": "पृष्ठहरू","presets.page_range_hint": "सबै पृष्ठहरू, वा जस्तै १-३, ५","presets.split": "प्रति पृष्ठ एउटा फाइल",+ "presets.pdf_tables_note": "PDF बाट, रेखाले बनाइएको हरेक तालिका आफ्नै शिट बन्छ (अर्को पेजमा जारी तालिका एउटै शिट रहन्छ), र अङ्क र मितिहरू वास्तविक मान बन्छन्। तालिकाबाहिरको पाठ छोडिन्छ।","presets.pdf_compression": "कम्प्रेस गर्नुहोस्","presets.pdf_compression.None": "कम्प्रेस नगर्नुहोस्","presets.pdf_compression.Screen": "सबैभन्दा सानो (तस्बिरहरू ७२ dpi मा)",diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.jsonindex 89ab9b12..d5adf8fc 100644--- a/src/Filee.App/Assets/i18n/pl.json+++ b/src/Filee.App/Assets/i18n/pl.json@@ -96,6 +96,7 @@"error.needs_shaping": "To pismo wymaga LibreOffice do poprawnej konwersji. Zainstaluj go w Ustawienia → Silniki","error.runtime_missing": "Brakuje pliku środowiska Microsoft Visual C++ potrzebnego temu silnikowi albo jest on nieaktualny. Zaktualizuj lub zainstaluj ponownie Filee albo zainstaluj Microsoft Visual C++ Redistributable (x64)","error.conversion_failed": "Silnik zgłosił błąd",+ "error.pdf_no_tables": "Ten PDF nie ma tabel narysowanych liniami, więc nie ma czego umieścić w arkuszu. Zeskanowany PDF w ogóle nie ma tekstu.","error.web_download_failed": "Nie udało się pobrać pliku","error.web_page": "Link otwiera stronę internetową, a nie plik. Filee nie pobierze pliku, który wymaga zalogowania: najpierw zapisz go w przeglądarce","error.web_too_large": "Plik jest większy niż 2 GB",@@ -537,6 +538,7 @@"presets.page_range": "Strony","presets.page_range_hint": "Wszystkie strony lub np. 1-3, 5","presets.split": "Jeden plik na stronę",+ "presets.pdf_tables_note": "Z PDF każda tabela narysowana liniami trafia na osobny arkusz (tabela ciągnąca się na następną stronę zostaje jednym arkuszem), a liczby i daty stają się prawdziwymi wartościami. Tekst poza tabelami jest pomijany.","presets.pdf_compression": "Kompresja","presets.pdf_compression.None": "Bez kompresji","presets.pdf_compression.Screen": "Najmniejszy (obrazy w 72 dpi)",diff --git a/src/Filee.App/Assets/i18n/pt-BR.json b/src/Filee.App/Assets/i18n/pt-BR.jsonindex c0c91ef0..0e30fef2 100644--- a/src/Filee.App/Assets/i18n/pt-BR.json+++ b/src/Filee.App/Assets/i18n/pt-BR.json@@ -96,6 +96,7 @@"error.needs_shaping": "Este alfabeto precisa do LibreOffice para converter corretamente. Instale-o em Configurações → Motores","error.runtime_missing": "Falta um arquivo do tempo de execução do Microsoft Visual C++ que este motor precisa, ou ele está desatualizado. Atualize ou reinstale o Filee, ou instale o Microsoft Visual C++ Redistributable (x64)","error.conversion_failed": "O motor informou um erro",+ "error.pdf_no_tables": "Este PDF não tem tabelas desenhadas com linhas, então não há nada para pôr em uma planilha. Um PDF digitalizado não tem texto nenhum.","error.web_download_failed": "Não foi possível baixar o arquivo","error.web_page": "O link abre uma página da web, não um arquivo. O Filee não baixa um arquivo que exige login: salve-o no navegador primeiro","error.web_too_large": "O arquivo é maior que 2 GB",@@ -537,6 +538,7 @@"presets.page_range": "Páginas","presets.page_range_hint": "Todas as páginas, ou por exemplo 1-3, 5","presets.split": "Um arquivo por página",+ "presets.pdf_tables_note": "De um PDF, cada tabela desenhada com linhas vira uma planilha própria (uma tabela que continua na página seguinte fica em uma só planilha), com números e datas como valores reais. O texto fora das tabelas fica de fora.","presets.pdf_compression": "Comprimir","presets.pdf_compression.None": "Não comprimir","presets.pdf_compression.Screen": "Menor (imagens a 72 dpi)",diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.jsonindex bf34fd1e..087e585b 100644--- a/src/Filee.App/Assets/i18n/ru.json+++ b/src/Filee.App/Assets/i18n/ru.json@@ -96,6 +96,7 @@"error.needs_shaping": "Чтобы правильно сконвертировать текст в этой системе письма, нужен LibreOffice. Установите его в разделе «Настройки → Движки»","error.runtime_missing": "Не хватает файла среды выполнения Microsoft Visual C++, нужного этому движку, или он устарел. Обновите или переустановите Filee либо установите Microsoft Visual C++ Redistributable (x64)","error.conversion_failed": "Движок сообщил об ошибке",+ "error.pdf_no_tables": "В этом PDF нет таблиц, нарисованных линиями, поэтому в таблицу Excel нечего поместить. В отсканированном PDF вообще нет текста.","error.web_download_failed": "Не удалось скачать файл","error.web_page": "Ссылка ведёт на веб-страницу, а не на файл. Файл, для которого нужен вход в аккаунт, Filee скачать не может: сначала сохраните его в браузере","error.web_too_large": "Файл больше 2 ГБ",@@ -537,6 +538,7 @@"presets.page_range": "Страницы","presets.page_range_hint": "Все страницы или, например, 1-3, 5","presets.split": "По файлу на страницу",+ "presets.pdf_tables_note": "Из PDF каждая таблица, нарисованная линиями, становится отдельным листом (таблица, продолжающаяся на следующей странице, остаётся одним листом), а числа и даты — настоящими значениями. Текст вне таблиц не сохраняется.","presets.pdf_compression": "Сжатие","presets.pdf_compression.None": "Не сжимать","presets.pdf_compression.Screen": "Минимальный размер (картинки 72 dpi)",diff --git a/src/Filee.App/Assets/i18n/th.json b/src/Filee.App/Assets/i18n/th.jsonindex 442f5563..4e085503 100644--- a/src/Filee.App/Assets/i18n/th.json+++ b/src/Filee.App/Assets/i18n/th.json@@ -90,6 +90,7 @@"error.needs_shaping": "ภาษานี้ต้องใช้ LibreOffice เพื่อแปลงให้ถูกต้อง ติดตั้งได้ในการตั้งค่า → เครื่องมือแปลงไฟล์","error.runtime_missing": "ไฟล์รันไทม์ Microsoft Visual C++ ที่เครื่องมือนี้ต้องใช้ขาดหายไปหรือล้าสมัย โปรดอัปเดตหรือติดตั้ง Filee ใหม่ หรือติดตั้ง Microsoft Visual C++ Redistributable (x64)","error.conversion_failed": "เครื่องมือแปลงไฟล์รายงานข้อผิดพลาด",+ "error.pdf_no_tables": "PDF นี้ไม่มีตารางที่วาดด้วยเส้น จึงไม่มีอะไรจะใส่ในสเปรดชีต PDF ที่สแกนมาไม่มีข้อความเลย","error.web_download_failed": "ไม่สามารถดาวน์โหลดไฟล์ได้","error.web_page": "ลิงก์นี้เปิดหน้าเว็บ ไม่ใช่ไฟล์ Filee ไม่สามารถดาวน์โหลดไฟล์ที่ต้องเข้าสู่ระบบได้ โปรดบันทึกจากเบราว์เซอร์ก่อน","error.web_too_large": "ไฟล์มีขนาดใหญ่กว่า 2 GB",@@ -522,6 +523,7 @@"presets.page_range": "หน้า","presets.page_range_hint": "ทุกหน้า หรือระบุ เช่น 1-3, 5","presets.split": "แยกหนึ่งไฟล์ต่อหนึ่งหน้า",+ "presets.pdf_tables_note": "จาก PDF ตารางที่วาดด้วยเส้นแต่ละตารางจะเป็นชีตของตัวเอง (ตารางที่ต่อไปยังหน้าถัดไปยังคงเป็นชีตเดียว) และตัวเลขกับวันที่จะเป็นค่าจริง ข้อความนอกตารางจะถูกละไว้","presets.pdf_compression": "บีบอัด","presets.pdf_compression.None": "ไม่บีบอัด","presets.pdf_compression.Screen": "ขนาดเล็กที่สุด (ภาพที่ 72 dpi)",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex d05a0068..ea219c2c 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -96,6 +96,7 @@"error.needs_shaping": "这种文字需要 LibreOffice 才能正确转换,请在“设置 → 转换引擎”中安装","error.runtime_missing": "此引擎所需的 Microsoft Visual C++ 运行库文件缺失或版本过旧。请更新或重新安装 Filee,或安装 Microsoft Visual C++ 可再发行程序包 (x64)","error.conversion_failed": "转换引擎出错",+ "error.pdf_no_tables": "此 PDF 没有用线条画出的表格,因此没有可放入电子表格的内容。扫描的 PDF 完全没有文字。","error.web_download_failed": "无法下载该文件","error.web_page": "该链接打开的是网页,不是文件。需要登录才能获取的文件 Filee 无法下载,请先在浏览器中保存","error.web_too_large": "文件大于 2 GB",@@ -537,6 +538,7 @@"presets.page_range": "页面","presets.page_range_hint": "全部,或如 1-3, 5","presets.split": "每页一个文件",+ "presets.pdf_tables_note": "从 PDF 转换时,每个用线条画出的表格成为一个工作表(续到下一页的表格仍为一个工作表),数字和日期会成为真正的数值。表格外的文字不包含在内。","presets.pdf_compression": "压缩","presets.pdf_compression.None": "不压缩","presets.pdf_compression.Screen": "最小(图片 72 dpi)",diff --git a/src/Filee.App/Assets/i18n/zh-TW.json b/src/Filee.App/Assets/i18n/zh-TW.jsonindex accf24b8..9ccf6fbf 100644--- a/src/Filee.App/Assets/i18n/zh-TW.json+++ b/src/Filee.App/Assets/i18n/zh-TW.json@@ -96,6 +96,7 @@"error.needs_shaping": "這種文字需要 LibreOffice 才能正確轉換,請在「設定 → 轉換引擎」中安裝","error.runtime_missing": "此引擎所需的 Microsoft Visual C++ 執行階段程式庫檔案缺失或版本過舊。請更新或重新安裝 Filee,或安裝 Microsoft Visual C++ 可轉散發套件 (x64)","error.conversion_failed": "轉換引擎出錯",+ "error.pdf_no_tables": "此 PDF 沒有以線條繪製的表格,因此沒有可放入試算表的內容。掃描的 PDF 完全沒有文字。","error.web_download_failed": "無法下載該檔案","error.web_page": "該連結開啟的是網頁,不是檔案。需要登入才能獲取的檔案 Filee 無法下載,請先在瀏覽器中儲存","error.web_too_large": "檔案大於 2 GB",@@ -537,6 +538,7 @@"presets.page_range": "頁面","presets.page_range_hint": "全部,或如 1-3, 5","presets.split": "每頁一個檔案",+ "presets.pdf_tables_note": "從 PDF 轉換時,每個以線條繪製的表格會成為一個工作表(延續到下一頁的表格仍為一個工作表),數字與日期會成為真正的數值。表格外的文字不包含在內。","presets.pdf_compression": "壓縮","presets.pdf_compression.None": "不壓縮","presets.pdf_compression.Screen": "最小(圖片 72 dpi)",diff --git a/src/Filee.App/ViewModels/PresetEditorViewModel.cs b/src/Filee.App/ViewModels/PresetEditorViewModel.csindex 5758e1c0..ef1be8d5 100644--- a/src/Filee.App/ViewModels/PresetEditorViewModel.cs+++ b/src/Filee.App/ViewModels/PresetEditorViewModel.cs@@ -203,7 +203,7 @@ public sealed partial class PresetEditorViewModel : ObservableObject[ObservableProperty][NotifyPropertyChangedFor(nameof(ShowImage), nameof(ShowTurnForPdf), nameof(ShowQuality), nameof(ShowTiff), nameof(ShowMultiPageTiff), nameof(ShowWebp), nameof(ShowIco),nameof(ShowZipResult), nameof(ShowPdf), nameof(ShowPdfBuild), nameof(ShowDocument), nameof(ShowLeaveOutPictures), nameof(ShowPdfSplit), nameof(ShowPdfCombine),- nameof(ShowPdfCompression), nameof(ShowPdfCompressionOptions),+ nameof(ShowPdfCompression), nameof(ShowPdfCompressionOptions), nameof(ShowPdfTablesNote),nameof(ShowMedia), nameof(ShowMediaQuality), nameof(ShowMaxHeight), nameof(ShowAudioBitrate), nameof(ShowRemoveAudio),nameof(ShowAudioChannels), nameof(ShowWav), nameof(VideoCodecs), nameof(VideoCodecChoice), nameof(ShowVideoCodec), nameof(ShowHardwareEncoding),nameof(AudioCodecs), nameof(AudioCodecChoice), nameof(ShowAudioCodec),@@ -497,6 +497,9 @@ public sealed partial class PresetEditorViewModel : ObservableObject/// <summary>Compression is for PDF → PDF; Ghostscript and metadata only matter while it is on.</summary>public bool ShowPdfCompression => TargetId == "pdf";++ /// <summary>XLSX: what a PDF becomes (its ruled tables, PdfTablesConverter).</summary>+ public bool ShowPdfTablesNote => TargetId == "xlsx";public bool ShowPdfCompressionOptions => ShowPdfCompression && CompressionLevel.Value != PdfCompression.None;/// <summary>PDF → a single-image format: the pages can be stacked into one tall image (TIFF, GIF, APNG and MNG keep pages).</summary>diff --git a/src/Filee.App/Views/PresetEditorView.axaml b/src/Filee.App/Views/PresetEditorView.axamlindex 717ccbcc..035c4d87 100644--- a/src/Filee.App/Views/PresetEditorView.axaml+++ b/src/Filee.App/Views/PresetEditorView.axaml@@ -310,6 +310,7 @@<TextBlock Classes="h2" Text="{DynamicResource presets.group.pdf}" /><CheckBox Content="{DynamicResource presets.merge}" IsChecked="{Binding Merge}" IsVisible="{Binding ShowPdfBuild}" /><CheckBox Content="{DynamicResource presets.split}" IsChecked="{Binding SplitPages}" IsVisible="{Binding ShowPdfSplit}" />+ <TextBlock Classes="caption" TextWrapping="Wrap" Text="{DynamicResource presets.pdf_tables_note}" IsVisible="{Binding ShowPdfTablesNote}" /><!-- PDF → PDF: make the file smaller --><StackPanel Spacing="2" IsVisible="{Binding ShowPdfCompression}"><Grid ColumnDefinitions="*,12,*">diff --git a/src/Filee.Engines/EngineRegistry.cs b/src/Filee.Engines/EngineRegistry.csindex dc9a98ed..3d7bc119 100644--- a/src/Filee.Engines/EngineRegistry.cs+++ b/src/Filee.Engines/EngineRegistry.cs@@ -55,6 +55,7 @@ public static class EngineRegistrynew DocxWriterConverter(),new PdfTextConverter(),new PdfSlidesConverter(),+ new PdfTablesConverter(),new EmlConverter(),new DataConverter(),new SubtitleConverter(),diff --git a/src/Filee.Engines/Pdf/PdfTablesConverter.cs b/src/Filee.Engines/Pdf/PdfTablesConverter.csnew file mode 100644index 00000000..fe0e43a1--- /dev/null+++ b/src/Filee.Engines/Pdf/PdfTablesConverter.cs@@ -0,0 +1,259 @@+// PDF → XLSX (#267): the tables drawn with lines in a PDF, one sheet each. The tables are the ones PDF → DOCX finds+// (PdfDocumentReader's ruled tables, with merged cells, column widths and row heights); text outside them is left out.+//+// - A table that goes on at the top of the next page with the same columns joins the one before it on one sheet; a+// header row repeated on the new page is left out.+// - Cells that read as numbers ("1,234.50", "(120)", "$9.99"), percentages ("12.5%") or dates with the year first+// ("2026-10-23", "2026. 10. 23.") become real numbers and dates, in a number format that shows them as the PDF+// did, so they can be calculated with. Anything else stays text: numbers with a leading zero (codes, phone numbers),+// more than 15 digits, a decimal comma, or day-first dates, which can't be told from month-first ones.+// - A PDF without such a table (or a scan, which has no text) fails with a message instead of an empty workbook.+// Tables aligned by white space only aren't found, as in PDF → DOCX.++using System.Globalization;+using System.Text;+using System.Text.RegularExpressions;+using Filee.Core.Conversion;+using Filee.Engines.Hwp.Hwpx;+using Filee.Engines.Infrastructure;+using Filee.Engines.Office.Sheets;++namespace Filee.Engines.Pdf;++/// <summary>PDF → XLSX: each table drawn with lines on its own sheet.</summary>+public sealed partial class PdfTablesConverter : IConverter+{+ /// <summary>Points per character of Excel's column width (Calibri 11: 7 px at 96 dpi).</summary>+ private const double PointsPerCharacter = 5.25;++ public string Id => "pdf-tables";+ public string DisplayName => "PDF tables (built-in)";+ public int MaxParallelism => 0;++ public IReadOnlyList<ConversionEdge> Edges { get; } = [new("pdf", "xlsx")];++ public EngineStatus GetStatus() => EngineStatus.Available("PDF → XLSX", EngineVersions.BuiltIn);++ public Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken) =>+ Task.Run<IReadOnlyList<string>>(() =>+ {+ var document = PdfDocumentReader.Read(step.InputPath, Path.Combine(step.WorkDirectory, $"media-{Guid.NewGuid():N}"));+ cancellationToken.ThrowIfCancellationRequested();+ progress?.Report(0.7);+ var book = Build(document);+ if (book.Sheets.Count == 0)+ throw new ConversionRefusedException("error.pdf_no_tables");+ var output = step.Output.Allocate("xlsx");+ if (output is null)+ return [];+ XlsxWriter.Write(book, output);+ progress?.Report(1);+ return [output];+ }, cancellationToken);++ /// <summary>A table and the page it is on (0-based).</summary>+ private sealed record Placed(HTable Table, int Page)+ {+ public bool FirstOnPage { get; set; }+ public bool LastOnPage { get; set; }+ }++ /// <summary>The document's tables as sheets: one per table, a table going on over the next page joined.</summary>+ internal static Workbook Build(HDocument document)+ {+ var tables = new List<Placed>();+ var page = -1;+ foreach (var section in document.Sections)+ {+ page++;+ foreach (var block in section.Blocks)+ {+ if (block is HParagraph { PageBreakBefore: true })+ page++;+ else if (block is HTable table && table.Rows.Count > 0)+ tables.Add(new Placed(table, page));+ }+ }+ for (var i = 0; i < tables.Count; i++)+ {+ tables[i].FirstOnPage = i == 0 || tables[i - 1].Page != tables[i].Page;+ tables[i].LastOnPage = i == tables.Count - 1 || tables[i + 1].Page != tables[i].Page;+ }++ var book = new Workbook();+ Worksheet? sheet = null;+ Placed? previous = null;+ string[]? header = null;+ var row = 0;+ foreach (var placed in tables)+ {+ var goesOn = previous is not null && sheet is not null && previous.LastOnPage && placed.FirstOnPage+ && placed.Page == previous.Page + 1 && SameColumns(previous.Table, placed.Table);+ var skip = 0;+ if (goesOn && header is not null && RowTexts(placed.Table.Rows[0]).SequenceEqual(header))+ skip = 1;+ if (!goesOn)+ {+ sheet = new Worksheet($"Table {book.Sheets.Count + 1}");+ book.Sheets.Add(sheet);+ row = 0;+ header = RowTexts(placed.Table.Rows[0]);+ SetColumnWidths(sheet, placed.Table);+ }+ row = Place(sheet!, placed.Table, row, skip);+ previous = placed;+ }+ return book;+ }++ /// <summary>Same number of columns, each within 5 % of the other table's width (or no widths to compare).</summary>+ private static bool SameColumns(HTable a, HTable b)+ {+ if (a.ColumnCount != b.ColumnCount)+ return false;+ if (a.ColumnWidths is not { } left || b.ColumnWidths is not { } right || left.Length != right.Length)+ return true;+ return left.Zip(right).All(w => Math.Abs(w.First - w.Second) <= 0.05 * Math.Max(w.First, w.Second) + 100);+ }++ private static void SetColumnWidths(Worksheet sheet, HTable table)+ {+ if (table.ColumnWidths is not { } widths)+ return;+ for (var column = 0; column < widths.Length; column++)+ sheet.ColumnWidths[column] = Math.Round(Math.Clamp(widths[column] / 100.0 / PointsPerCharacter, 2, 100), 2);+ }++ /// <summary>Writes the table's rows from <paramref name="top"/> on, leaving out its first <paramref name="skip"/>; returns the next free row.</summary>+ private static int Place(Worksheet sheet, HTable table, int top, int skip)+ {+ var taken = new HashSet<(int, int)>();+ var row = top;+ foreach (var source in table.Rows.Skip(skip))+ {+ if (source.Height is { } height && height > 0)+ sheet.RowHeights[row] = Math.Round(height / 100.0, 2);+ var column = 0;+ foreach (var cell in source.Cells)+ {+ if (cell.Column >= 0)+ column = cell.Column;+ while (taken.Contains((row, column)))+ column++;+ var style = StyleOf(cell);+ var text = Text(cell);+ sheet.Set(row, column, Shown(text, style));+ var rows = Math.Max(1, cell.RowSpan);+ var columns = Math.Max(1, cell.ColSpan);+ for (var r = row; r < row + rows; r++)+ for (var c = column; c < column + columns; c++)+ {+ taken.Add((r, c));+ // The rest of a merged area keeps the borders, as Excel draws them from every cell.+ if (r != row || c != column)+ sheet.Set(r, c, new SheetCell("", style));+ }+ if (rows > 1 || columns > 1)+ sheet.Merges.Add(new CellRange(row, column, row + rows - 1, column + columns - 1));+ column += columns;+ }+ row++;+ }+ return Math.Max(row, taken.Count == 0 ? row : taken.Max(t => t.Item1) + 1);+ }++ private static CellStyle StyleOf(HCell cell) => new()+ {+ Bold = cell.Blocks.OfType<HParagraph>().SelectMany(p => p.Inlines).OfType<HText>().ToList() is { Count: > 0 } texts+ && texts.All(t => t.Format.Bold == true || t.Text.Trim().Length == 0),+ Fill = cell.Fill,+ Wrap = true,+ VerticalAlign = cell.VerticalAlign switch+ {+ HVerticalAlign.Center => CellVerticalAlign.Center,+ HVerticalAlign.Bottom => CellVerticalAlign.Bottom,+ _ => CellVerticalAlign.Top,+ },+ Left = Thin,+ Right = Thin,+ Top = Thin,+ Bottom = Thin,+ };++ private static readonly CellBorder Thin = new("thin", "#000000");++ private static string[] RowTexts(HRow row) => [.. row.Cells.Select(Text)];++ /// <summary>A cell's text: its paragraphs as lines.</summary>+ private static string Text(HCell cell)+ {+ var lines = new List<string>();+ foreach (var paragraph in cell.Blocks.OfType<HParagraph>())+ {+ var line = new StringBuilder();+ foreach (var inline in paragraph.Inlines)+ line.Append(inline switch { HText text => text.Text, HTab => "\t", HLineBreak => "\n", _ => "" });+ lines.Add(line.ToString());+ }+ return string.Join('\n', lines).Trim();+ }++ // ───────────────────────── Numbers and dates ─────────────────────────++ /// <summary>A cell for text as the PDF shows it: a number or date with a matching format, or text.</summary>+ internal static SheetCell Shown(string text, CellStyle style)+ {+ if (Number(text) is { } number)+ return new SheetCell(text, style, IsNumber: true) { Value = number.Value, NumberFormat = number.Format };+ if (Date(text) is { } date)+ return new SheetCell(text, style, IsNumber: true) { Value = date.Value, NumberFormat = date.Format };+ return new SheetCell(text, style);+ }++ /// <summary>"1,234.50", "-7", "(120)", "$9.99", "12.5%" as a value and an Excel number format; null otherwise.</summary>+ internal static (double Value, string Format)? Number(string text)+ {+ if (NumberPattern().Match(text.Trim()) is not { Success: true } match)+ return null;+ var whole = match.Groups["whole"].Value;+ var fraction = match.Groups["fraction"].Value;+ var digits = whole.Replace(",", "") + fraction;+ // Codes and phone numbers keep their leading zero; Excel holds 15 significant digits.+ if ((whole.Length > 1 && whole[0] == '0') || digits.TrimStart('0').Length > 15)+ return null;+ var negative = match.Groups["minus"].Success || match.Groups["open"].Success;+ if (match.Groups["open"].Success != match.Groups["close"].Success)+ return null;+ var value = double.Parse(whole.Replace(",", "") + (fraction.Length > 0 ? "." + fraction : ""), CultureInfo.InvariantCulture);+ var format = (whole.Contains(',') ? "#,##0" : "0") + (fraction.Length > 0 ? "." + new string('0', fraction.Length) : "");+ if (match.Groups["percent"].Success)+ {+ value /= 100;+ format += "%";+ }+ if (match.Groups["currency"].Value is { Length: > 0 } currency)+ format = $"\"{currency}\"{format}";+ if (match.Groups["open"].Success)+ format = $"{format};({format})";+ return (negative ? -value : value, format);+ }++ /// <summary>"2026-10-23", "2026/1/5", "2026. 10. 23." as an Excel date serial and format; null otherwise.</summary>+ internal static (double Value, string Format)? Date(string text)+ {+ if (DatePattern().Match(text.Trim()) is not { Success: true } match)+ return null;+ var (year, month, day) = (match.Groups["y"].Value, match.Groups["m"].Value, match.Groups["d"].Value);+ if (!DateOnly.TryParseExact($"{year}-{month.PadLeft(2, '0')}-{day.PadLeft(2, '0')}", "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var date))+ return null;+ var separator = match.Groups["sep"].Value;+ var format = "yyyy" + separator + (month.Length == 2 ? "mm" : "m") + separator + (day.Length == 2 ? "dd" : "d") + match.Groups["end"].Value;+ return (date.DayNumber - new DateOnly(1899, 12, 30).DayNumber, format);+ }++ [GeneratedRegex(@"^(?<minus>-)?(?<open>\()?(?<currency>[$€£¥₩₹])?(?<whole>\d{1,3}(?:,\d{3})+|\d+)(?:\.(?<fraction>\d+))?(?<percent>%)?(?<close>\))?$")]+ private static partial Regex NumberPattern();++ [GeneratedRegex(@"^(?<y>\d{4})(?<sep>-|/|\. ?)(?<m>\d{1,2})\k<sep>(?<d>\d{1,2})(?<end>\.?)$")]+ private static partial Regex DatePattern();+}diff --git a/tests/Filee.Engines.Tests/PdfTablesTests.cs b/tests/Filee.Engines.Tests/PdfTablesTests.csnew file mode 100644index 00000000..b61f9fd4--- /dev/null+++ b/tests/Filee.Engines.Tests/PdfTablesTests.cs@@ -0,0 +1,143 @@+// PDF → XLSX (#267): each table drawn with lines on its own sheet, with numbers and dates as real values, merged+// cells and column widths, a table going on over the next page joined, and a clear failure when there is no table.++using Filee.Core.Conversion;+using Filee.Core.Presets;+using Filee.Engines.Office.Sheets;+using Filee.Engines.Pdf;++namespace Filee.Engines.Tests;++public class PdfTablesTests(EngineFixture fx) : IClassFixture<EngineFixture>+{+ /// <summary>A grid of rules with text in its cells; a null cell is covered by the one to its left (no rule between).</summary>+ private static void Table(PdfBuilder pdf, double top, double[] xs, string?[][] rows, bool boldHeader = true)+ {+ var y = top;+ foreach (var row in rows)+ {+ pdf.Rule(xs[0], y, xs[^1], y);+ for (var c = 0; c < row.Length; c++)+ {+ if (c == 0 || row[c] is not null)+ pdf.Rule(xs[c], y, xs[c], y + 20);+ if (row[c] is { } text)+ pdf.Line(text, 10, pdf.Font(bold: boldHeader && y == top), xs[c] + 4, y + 14);+ }+ pdf.Rule(xs[^1], y, xs[^1], y + 20);+ y += 20;+ }+ pdf.Rule(xs[0], y, xs[^1], y);+ }++ private async Task<Workbook> ConvertAsync(string pdf)+ {+ var job = await fx.ConvertAsync([pdf], new Preset { TargetFormat = "xlsx" });+ Assert.True(job.State == JobState.Completed, string.Join("; ", job.Files.Select(f => $"{f.ErrorKey} {f.ErrorDetail}")));+ return XlsxReader.Read(job.Outputs.Single());+ }++ [Fact]+ public async Task Numbers_dates_and_merged_cells_reach_the_sheet()+ {+ var pdf = new PdfBuilder().NewPage();+ pdf.Paragraph("Sales by quarter, as reported.", 11, pdf.Font(), 50, 80, 495, 14);+ Table(pdf, 110, [50, 200, 350, 545],+ [+ ["Item", "Amount", "Date"],+ ["Paper", "1,234.50", "2026-10-23"],+ ["Ink", "(120)", "2026/1/5"],+ ["Share", "12.5%", "007"],+ ["Total for the year", null, "$9.99"],+ ]);+ var book = await ConvertAsync(pdf.Save(Path.Combine(fx.NewFolder(), "sales.pdf")));++ var sheet = Assert.Single(book.Sheets);+ Assert.Equal("Item", sheet.Get(0, 0)!.Text);+ Assert.Equal((1234.5, "#,##0.00"), (sheet.Get(1, 1)!.Value!.Value, sheet.Get(1, 1)!.NumberFormat));+ Assert.Equal(-120, sheet.Get(2, 1)!.Value);+ Assert.Equal(0.125, sheet.Get(3, 1)!.Value!.Value, 9);+ Assert.Equal(new DateOnly(2026, 10, 23).DayNumber - new DateOnly(1899, 12, 30).DayNumber, sheet.Get(1, 2)!.Value);+ Assert.Equal(new DateOnly(2026, 1, 5).DayNumber - new DateOnly(1899, 12, 30).DayNumber, sheet.Get(2, 2)!.Value);+ Assert.Null(sheet.Get(3, 2)!.Value); // a code with a leading zero stays text+ Assert.Equal("007", sheet.Get(3, 2)!.Text);+ Assert.Equal(9.99, sheet.Get(4, 2)!.Value);+ Assert.Contains(new CellRange(4, 0, 4, 1), sheet.Merges);+ Assert.Null(sheet.Get(0, 0)!.Value); // the paragraph above the table isn't on the sheet+ Assert.DoesNotContain(sheet.Rows.Values.SelectMany(r => r.Values), c => c.Text.Contains("Sales by quarter"));+ // Column widths follow the PDF: the last column is the widest.+ Assert.True(sheet.ColumnWidth(2) > sheet.ColumnWidth(0));+ }++ [Fact]+ public async Task A_table_going_on_over_the_next_page_is_one_sheet_and_another_table_its_own()+ {+ double[] xs = [50, 250, 545];+ var pdf = new PdfBuilder().NewPage();+ Table(pdf, 600, xs, [["Name", "Size"], ["a.pdf", "10"], ["b.pdf", "20"]]);+ pdf.NewPage();+ Table(pdf, 60, xs, [["Name", "Size"], ["c.pdf", "30"]]); // header repeated on the new page+ Table(pdf, 300, [50, 150, 300, 545], [["Code", "City", "Country"], ["SEL", "Seoul", "Korea"]]);+ var book = await ConvertAsync(pdf.Save(Path.Combine(fx.NewFolder(), "files.pdf")));++ Assert.Equal(2, book.Sheets.Count);+ var files = book.Sheets[0];+ Assert.Equal(["Name", "a.pdf", "b.pdf", "c.pdf"], Enumerable.Range(0, 4).Select(r => files.Get(r, 0)!.Text));+ Assert.Equal(30, files.Get(3, 1)!.Value);+ Assert.Null(files.Get(4, 0));+ Assert.Equal("Seoul", book.Sheets[1].Get(1, 1)!.Text);+ }++ [Fact]+ public async Task A_pdf_without_tables_fails_with_a_message()+ {+ var pdf = new PdfBuilder().NewPage();+ pdf.Paragraph("Only a letter, no table here.", 11, pdf.Font(), 50, 80, 495, 14);++ var job = await fx.ConvertAsync([pdf.Save(Path.Combine(fx.NewFolder(), "letter.pdf"))], new Preset { TargetFormat = "xlsx" });++ Assert.Equal(JobState.Failed, job.State);+ Assert.Equal("error.pdf_no_tables", job.Files[0].ErrorKey);+ }++ [Theory]+ [InlineData("1,234", 1234d, "#,##0")]+ [InlineData("-7", -7d, "0")]+ [InlineData("0.5", 0.5, "0.0")]+ [InlineData("€1,000.00", 1000d, "\"€\"#,##0.00")]+ [InlineData("(1,200.50)", -1200.5, "#,##0.00;(#,##0.00)")]+ [InlineData("50%", 0.5, "0%")]+ public void Numbers_keep_their_shown_format(string text, double value, string format)+ {+ var number = PdfTablesConverter.Number(text);+ Assert.NotNull(number);+ Assert.Equal(value, number.Value.Value, 9);+ Assert.Equal(format, number.Value.Format);+ }++ [Theory]+ [InlineData("012")]+ [InlineData("1,23")]+ [InlineData("1.234,50")]+ [InlineData("12 KB")]+ [InlineData("(5")]+ [InlineData("1234567890123456")]+ [InlineData("10/23/2026")]+ public void Other_text_stays_text(string text)+ {+ Assert.Null(PdfTablesConverter.Number(text));+ Assert.Null(PdfTablesConverter.Date(text));+ }++ [Theory]+ [InlineData("2026-10-23", "yyyy-mm-dd")]+ [InlineData("2026/1/5", "yyyy/m/d")]+ [InlineData("2026. 10. 23.", "yyyy. mm. dd.")]+ public void Dates_with_the_year_first_become_dates(string text, string format)+ {+ var date = PdfTablesConverter.Date(text);+ Assert.NotNull(date);+ Assert.Equal(format, date.Value.Format);+ Assert.Null(PdfTablesConverter.Date("2026-02-30")); // not a day+ }+}