Demo 17 - Data Binding and Spreadsheets

Abstract

This demo focuses on spreadsheet import and styled data extraction.

1 Standard Import (Unchecked)

For comparison, see how the same table is rendered using standard import (without the types attribute). The spreadsheet is ingested with its inconsistencies, potentially passing semantically incorrect data (like "10 units" instead of number 10) silently into your final document:

Table 1. Standard Import (Excel)
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
Source: Validation spreadsheet (data.xlsx) without type checking

The LibreOffice (.ods) version:

Table 2. Standard Import (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
Source: Validation spreadsheet (data.ods) without type checking

2 Dynamic Formula Evaluation

In this complex example, we import the Formulas sheet containing dynamic columns like Total (using SUM), Average (using AVERAGE), and Performance (using IF). MarkCharm and its internal spreadsheet engine (formulas) calculate equations in real time during import.

Cells respect both currency formatting and correct type extraction (including conditional logic returning string).

Table 3. Dynamic Formulas (Excel)
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
Source: Formulas sheet (data.xlsx)

And the same dynamic test evaluating functions inside a native .ods file:

Table 4. Dynamic Formulas (ODS)
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
Source: Formulas sheet (data.ods)

3 Rigorous Rich Styling Preservation

MarkCharm's xlsx_loader (and its counterpart ods_loader) is not a simple plain text extractor — it maps the visual architecture and styling of spreadsheets directly to inline HTML.

Our engine processes the following source spreadsheet layout metadata:

Below, we import a heavily styled spreadsheet. Note how individual alignment options (right-aligned text), colors, and borders are captured. By default, the table fluently adapts to page layout (ignoring fixed Excel heights and widths for responsive presentation):

Table 5. No Title
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
Source: Base styled spreadsheet (styled_table.xlsx)

Faithfully extracted version from LibreOffice (.ods):

Table 6. No Title
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
Source: Base styled spreadsheet (styled_table.ods)

4 Performance with Extreme Palettes (Magic Square)

To stress-test the RGB -> HEX color extraction engine, we generated a classic 5x5 Magic Square (where the sum of all rows, columns, and diagonals equals 65).

Each cell has a distinct rainbow color filled dynamically based on its numerical value. Font color automatically adapts between black and white depending on background luminosity:

Chart 1. Magic Square (Excel)
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
Source: Stylized magic square (styled_table.xlsx)

The ODS version:

Chart 2. Magic Square (ODS)
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
Source: Stylized magic square (styled_table.ods)

5 Raw Mode Import

Often you want to import data without bringing along heavy formatting embedded by spreadsheet users. For these scenarios, the flag styled="false" is supported in MarkCharm.

Below is the same table and region A1:F10 imported without styles (notice how colors, fixed dimensions, borders, and typography were suppressed to inherit native document styles):

Table 7. No Title
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
Source: Base spreadsheet in raw mode (styled_table.xlsx)

Raw extraction via LibreOffice (.ods):

Table 8. No Title
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
Source: Base spreadsheet in raw mode (styled_table.ods)

6 Geometry and Alignment Stress Test

Below, we import a "Scorecard" testing spreadsheet extractor boundaries. It showcases extreme vertical alignments (Top, Middle, Bottom), combined horizontal alignments, and varied border thicknesses.

To prove geometry was extracted (40px and 60px row heights, asymmetric column widths), we pass the flag geometry="true".

Additionally, we intentionally pass title_cell="A1" and title="My Flawed Title" simultaneously. You can see warning [WARNING] MCW-SPR-001 in the compiler log complaining about this collision (where title_cell takes precedence):

Chart 3. Scorecard (Excel)
Top Left Center Middle Bottom Right
Rotated? Merged B3:C3
Source: Stress scorecard (styled_table.xlsx)

LibreOffice (.ods) version:

Chart 4. Scorecard (ODS)
Top Left Center Middle Bottom Right
Rotated? Merged B3:C3
Source: Stress scorecard (styled_table.ods)

7 Grayscale Conversion via LibreOffice (.ods)

For technical reports requiring printing or subdued palettes, MarkCharm allows neutralizing spreadsheet colors while keeping original structure.

Below, we extract styled_table and the Magic Square in grayscale (grayscale="true"). The engine dynamically calculates YIQ luminosity to convert all RGB colors into shades of gray:

Table 9. Grayscale (Excel)
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
Source: Grayscale spreadsheet from Excel (styled_table.xlsx)
Table 10. Grayscale (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
Source: Grayscale spreadsheet from LibreOffice (styled_table.ods)
Chart 5. Grayscale Magic Square (Excel)
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
Source: Grayscale magic square from Excel (styled_table.xlsx)
Chart 6. Grayscale Magic Square (ODS)
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
Source: Grayscale magic square from LibreOffice (styled_table.ods)

8 Usage Notes and Requirements

Note

When currency is expected, a cell with a pure number that lacks active currency formatting in Excel will be considered invalid. This reinforces visual semantics for the spreadsheet operator.


9 Dynamic Metadata Extraction and Collision Detection

MarkCharm supports extracting Title, Source, Notes, and Observations (Misc) directly from your spreadsheet (.xlsx and .ods).

In the table below, we extract metadata dynamically pointing to arbitrary cells as proof of concept (e.g. A1 as source). We also force an intentional error declaring title_cell="A1" twice. The compiler will emit [WARNING] MCW-SPR-004: Multiple assignments for attribute 'title_cell'. Additionally, static text Source: My Static Source is included after the table. The compiler will emit MCW-SPR-002 warning that the spreadsheet dynamic version (source_cell) won the collision and overwrote the static text!

Excel Version (.xlsx):

Table 11. Collision Detection (Excel)
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
Source: ID
Notes: Produto
My Static Observation

LibreOffice Version (.ods):

Table 12. Collision Detection (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
Source: ID
Notes: Produto
My Static Observation

10 Reactive Data Binding

Below, we demonstrate the {$DATA} directive connecting this document to an external JSON (data.json). MarkCharm extracts keys from JSON and automatically converts them into ready-to-use macros!

Dynamic Project Report