Abstract
This demo showcases rigorous semantic validation functionality when importing spreadsheet data. Through \strictcell commands and type declarations in the \spreadsheet directive, the compiler requires extracted data to strictly match expected types (number, string, currency, date, etc.). Inconsistencies generate clear error messages, preventing silent document corruption.
Below we import table data.xlsx expecting exact structure: number, string, currency, number. Since the spreadsheet has intentional errors in data rows, the rendered table will flag explicit errors and the compiler would alert the author.
| ID | Produto | Receita (Esperado Moeda) | Qtd (Esperado Num) |
|---|---|---|---|
| 1 | Cadeira Gamer | [MC-WARN: Expected currency] | [MC-WARN: Expected number] |
| 2 | Mouse | R$ 120.00 | 50 |
| 3 | [MC-WARN: Expected string] | R$ 300.00 | 5 |
And the corresponding version processed from LibreOffice (.ods) for visual and semantic comparison:
| ID | Produto | Receita (Esperado Moeda) | Qtd (Esperado Num) |
|---|---|---|---|
| 1 | Cadeira Gamer | [MC-WARN: Expected currency] | [MC-WARN: Expected number] |
| 2 | Mouse | R$120,00 | 50 |
| 3 | [MC-WARN: Expected string] | R$300,00 | 5 |
For comparison purposes, see how the same table is rendered if we use standard import (without the types attribute). The spreadsheet is ingested with its inconsistencies, potentially introducing semantically incorrect data (such as “10 un” instead of the number 10) into your final document silently:
| ID | Produto | Receita (Esperado Moeda) | Qtd (Esperado Num) |
|---|---|---|---|
| 1 | Cadeira Gamer | 1500.5 | 10 un |
| 2 | Mouse | R$ 120.00 | 50 |
| 3 | R$ 300.00 | 5 |
The LibreOffice (.ods) version:
| ID | Produto | Receita (Esperado Moeda) | Qtd (Esperado Num) |
|---|---|---|---|
| 1 | Cadeira Gamer | 1500,5 | 10 un |
| 2 | Mouse | R$120,00 | 50 |
| 3 | R$300,00 | 5 |
In this complex example, we import the Formulas sheet, which contains dynamic columns such as Total (using SUM), Average (using AVERAGE), and Performance (using IF). MarkCharm and its internal spreadsheet engine (formulas) calculate the equations in real time during import.
The cells continue to respect both the currency format and correct type extraction (including conditional logic returning a string).
| Vendedor | Vendas Q1 | Vendas Q2 | Total | Média | Desempenho (IF) |
|---|---|---|---|---|---|
| Ana | R$ 5,000.00 | R$ 6,000.00 | R$ 11,000.00 | R$ 5,500.00 | Excelente |
| Bruno | R$ 2,000.00 | R$ 3,000.00 | R$ 5,000.00 | R$ 2,500.00 | Bom |
| Carlos | R$ 8,000.00 | R$ 9,000.00 | R$ 17,000.00 | R$ 8,500.00 | Excelente |
And the same dynamic test evaluating functions within a native .ods file:
| Vendedor | Vendas Q1 | Vendas Q2 | Total | Média | Desempenho (IF) |
|---|---|---|---|---|---|
| Ana | R$5.000,00 | R$6.000,00 | R$11.000,00 | R$5.500,00 | Excelente |
| Bruno | R$2.000,00 | R$3.000,00 | R$5.000,00 | R$2.500,00 | Bom |
| Carlos | R$8.000,00 | R$9.000,00 | R$17.000,00 | R$8.500,00 | Excelente |
It is also possible to check types in individual cells via \strictcell and in \cell{..., expect="..."}:
From Excel (.xlsx):
And identical behavior from LibreOffice (.ods):
MarkCharm's xlsx_loader (and its counterpart ods_loader) is not just a simple text extractor — it seamlessly maps the visual architecture and styling of spreadsheets directly into inline HTML.
Our engine natively processes the following layout metadata from the source spreadsheet:
pt), bold, italic, text colors (RGB to HEX), and underlines.rowspan) and horizontally merged cells (colspan).background-color).1px solid #000).Below, we import a heavily styled spreadsheet (packed with background colors, white or red text, merged categories, and a 'Grand Total' row with thick borders). Notice how individual alignment options (right-aligned text), colors, and borders were captured perfectly. By default, the table adapts fluidly to the page layout (ignoring Excel's fixed heights and widths for a more responsive look):
| Tabela de Estilos Avançados (Bordas e Cores) | |||||
| ID | Produto | Categoria | Preço | Estoque | Status |
| 1 | Notebook | Eletrônicos | 3500 | 15 | Ativo |
| 2 | Mouse Gamer RGB | 150 | 50 | Ativo | |
| 3 | Cadeira Ergonomica | Móveis | 800 | 0 | Esgotado |
| 4 | Mesa de Escritório | 1200 | 5 | Ativo | |
| 5 | Teclado Mecânico (Red) | Acessórios | 300 | 10 | Promoção |
| 6 | Monitor Ultrawide (Blue) | 2100 | 2 | Limitado | |
| 7 | Headset Pro (Green) | 450 | 30 | Lançamento | |
| Total Geral | 8500 | ||||
Faithfully extracted version from LibreOffice (.ods):
| Tabela de Estilos Avançados (Bordas e Cores) | |||||
| ID | Produto | Categoria | Preço | Estoque | Status |
| 1 | Notebook | Eletrônicos | 3500 | 15 | Ativo |
| 2 | Mouse Gamer RGB | 150 | 50 | Ativo | |
| 3 | Cadeira Ergonomica | Móveis | 800 | 0 | Esgotado |
| 4 | Mesa de Escritório | 1200 | 5 | Ativo | |
| 5 | Teclado Mecânico (Red) | Acessórios | 300 | 10 | Promoção |
| 6 | Monitor Ultrawide (Blue) | 2100 | 2 | Limitado | |
| 7 | Headset Pro (Green) | 450 | 30 | Lançamento | |
| Total Geral | 8500 | ||||
To stress-test the RGB -> HEX color extraction engine, below we generate a classic 5x5 Magic Square (where the sum of all rows, columns, and diagonals yields the same value: 65).
Each cell has a distinct rainbow color, dynamically filled based on its numeric value. The font color automatically adapts between black and white depending on background luminance:
| 17 | 24 | 1 | 8 | 15 |
| 23 | 5 | 7 | 14 | 16 |
| 4 | 6 | 13 | 20 | 22 |
| 10 | 12 | 19 | 21 | 3 |
| 11 | 18 | 25 | 2 | 9 |
The ODS version:
| 17 | 24 | 1 | 8 | 15 |
| 23 | 5 | 7 | 14 | 16 |
| 4 | 6 | 13 | 20 | 22 |
| 10 | 12 | 19 | 21 | 3 |
| 11 | 18 | 25 | 2 | 9 |
Often you only want to import data without bringing along the heavy formatting embedded by spreadsheet users (such as gaudy colors or fonts diverging from the document standard). For these scenarios, the styled="false" flag was introduced in the MarkCharm infrastructure.
Below we have the exact same table and A1:F10 region imported without styles (notice how colors, fixed dimensions, borders, and typography have all been suppressed to inherit the clean native appearance of the document):
| Tabela de Estilos Avançados (Bordas e Cores) | |||||
| ID | Produto | Categoria | Preço | Estoque | Status |
| 1 | Notebook | Eletrônicos | 3500 | 15 | Ativo |
| 2 | Mouse Gamer RGB | 150 | 50 | Ativo | |
| 3 | Cadeira Ergonomica | Móveis | 800 | 0 | Esgotado |
| 4 | Mesa de Escritório | 1200 | 5 | Ativo | |
| 5 | Teclado Mecânico (Red) | Acessórios | 300 | 10 | Promoção |
| 6 | Monitor Ultrawide (Blue) | 2100 | 2 | Limitado | |
| 7 | Headset Pro (Green) | 450 | 30 | Lançamento | |
| Total Geral | 8500 | ||||
Raw extraction via LibreOffice (.ods):
| Tabela de Estilos Avançados (Bordas e Cores) | |||||
| ID | Produto | Categoria | Preço | Estoque | Status |
| 1 | Notebook | Eletrônicos | 3500 | 15 | Ativo |
| 2 | Mouse Gamer RGB | 150 | 50 | Ativo | |
| 3 | Cadeira Ergonomica | Móveis | 800 | 0 | Esgotado |
| 4 | Mesa de Escritório | 1200 | 5 | Ativo | |
| 5 | Teclado Mecânico (Red) | Acessórios | 300 | 10 | Promoção |
| 6 | Monitor Ultrawide (Blue) | 2100 | 2 | Limitado | |
| 7 | Headset Pro (Green) | 450 | 30 | Lançamento | |
| Total Geral | 8500 | ||||
Below, we import a “Scorecard” that tests the limits of the spreadsheet extractor. It showcases extreme vertical alignments (Top, Middle, Bottom), combined horizontal alignments, and varied border thicknesses (thin gray vs. thick black).
To prove that geometry was faithfully extracted (row heights of 40px and 60px, asymmetric column widths), we pass the flag geometry="true".
Additionally, we intentionally pass both title_cell="A1" and title="My Failed Title" flags at the same time. You will be able to see in the compiler log the warning [WARNING] MCW-SPR-001 reporting this collision (where title_cell takes precedence):
| Top Left | Center Middle | Bottom Right |
| Rotated? | Merged B3:C3 | |
LibreOffice (.ods) version:
| Top Left | Center Middle | Bottom Right |
| Rotated? | Merged B3:C3 | |
For academic reports requiring print or sober color palettes, MarkCharm allows neutralizing loud spreadsheet colors (backgrounds, text, and borders) while preserving the original structure.
Below, we extract the same colorful spreadsheet styled_table and the Magic Square, using the native LibreOffice (.ods) version and activating the grayscale="true" directive. The engine dynamically calculates YIQ luminance to convert all RGB colors seamlessly into grayscale:
| Tabela de Estilos Avançados (Bordas e Cores) | |||||
| ID | Produto | Categoria | Preço | Estoque | Status |
| 1 | Notebook | Eletrônicos | 3500 | 15 | Ativo |
| 2 | Mouse Gamer RGB | 150 | 50 | Ativo | |
| 3 | Cadeira Ergonomica | Móveis | 800 | 0 | Esgotado |
| 4 | Mesa de Escritório | 1200 | 5 | Ativo | |
| 5 | Teclado Mecânico (Red) | Acessórios | 300 | 10 | Promoção |
| 6 | Monitor Ultrawide (Blue) | 2100 | 2 | Limitado | |
| 7 | Headset Pro (Green) | 450 | 30 | Lançamento | |
| Total Geral | 8500 | ||||
| Tabela de Estilos Avançados (Bordas e Cores) | |||||
| ID | Produto | Categoria | Preço | Estoque | Status |
| 1 | Notebook | Eletrônicos | 3500 | 15 | Ativo |
| 2 | Mouse Gamer RGB | 150 | 50 | Ativo | |
| 3 | Cadeira Ergonomica | Móveis | 800 | 0 | Esgotado |
| 4 | Mesa de Escritório | 1200 | 5 | Ativo | |
| 5 | Teclado Mecânico (Red) | Acessórios | 300 | 10 | Promoção |
| 6 | Monitor Ultrawide (Blue) | 2100 | 2 | Limitado | |
| 7 | Headset Pro (Green) | 450 | 30 | Lançamento | |
| Total Geral | 8500 | ||||
| 17 | 24 | 1 | 8 | 15 |
| 23 | 5 | 7 | 14 | 16 |
| 4 | 6 | 13 | 20 | 22 |
| 10 | 12 | 19 | 21 | 3 |
| 11 | 18 | 25 | 2 | 9 |
| 17 | 24 | 1 | 8 | 15 |
| 23 | 5 | 7 | 14 | 16 |
| 4 | 6 | 13 | 20 | 22 |
| 10 | 12 | 19 | 21 | 3 |
| 11 | 18 | 25 | 2 | 9 |
When currency is required, a cell with a pure number that lacks active accounting/currency formatting in Excel will be considered invalid. This reinforces visual semantics for the spreadsheet operator.
MarkCharm now supports extracting not only the title, but also the Source, Notes, and Observations (Misc) directly from your spreadsheet (both .xlsx and .ods), ensuring that if the value is updated in Excel, the document automatically reflects it.
In the table below, we extract metadata dynamically by pointing to arbitrary cells merely as a proof of concept (e.g. A1 as source). We also trigger an intentional error by declaring title_cell="A1" twice. The compiler will emit the warning [WARNING] MCW-SPR-004: Multiple assignments for attribute 'title_cell'. Additionally, we include static markdown text Source: My Static Source right after the table. The compiler will emit warning MCW-SPR-002 notifying that the spreadsheet's dynamic version (source_cell) won the collision and overwrote the static text!
Excel Version (.xlsx):
| ID | Produto | Receita (Esperado Moeda) | Qtd (Esperado Num) |
| 1 | Cadeira Gamer | 1500.5 | 10 un |
| 2 | Mouse | R$ 120.00 | 50 |
| 3 | R$ 300.00 | 5 |
LibreOffice Version (.ods):
| ID | Produto | Receita (Esperado Moeda) | Qtd (Esperado Num) |
| 1 | Cadeira Gamer | 1500,5 | 10 un |
| 2 | Mouse | R$120,00 | 50 |
| 3 | R$300,00 | 5 |