The demo folder only had a toy todo list, which did not show that a non-trivial application can be written in Lua and shipped as a single compiled binary. This adds LuaSheet: a tokenizer, a formula parser, a lazy evaluator with cycle detection, range-aware builtin functions, ASCII/CSV rendering and a benchmark, all driven by a CLI entry point. Everything stays plain Lua under Demo/: no C++ change is needed to build or run it.
133 lines
1.8 KiB
Lua
133 lines
1.8 KiB
Lua
-- Sample workbooks, kept as text in the worksheet format read by
|
|
-- sheet.from_text(): "A1: value" or "B4: =B3*12", '#' for comments.
|
|
local M = {}
|
|
|
|
M.budget = [[
|
|
# Budget 2026 : un classeur complet, calcule a la volee.
|
|
A1: Budget 2026 - foyer
|
|
A3: Poste
|
|
B3: Mensuel
|
|
C3: Annuel
|
|
D3: Part
|
|
|
|
A4: Loyer
|
|
B4: 820
|
|
C4: =B4*12
|
|
D4 %: =C4/$C$11
|
|
|
|
A5: Courses
|
|
B5: 430
|
|
C5: =B5*12
|
|
D5 %: =C5/$C$11
|
|
|
|
A6: Transport
|
|
B6: 95
|
|
C6: =B6*12
|
|
D6 %: =C6/$C$11
|
|
|
|
A7: Energie
|
|
B7: 118
|
|
C7: =B7*12
|
|
D7 %: =C7/$C$11
|
|
|
|
A8: Loisirs
|
|
B8: 160
|
|
C8: =B8*12
|
|
D8 %: =C8/$C$11
|
|
|
|
A9: Epargne
|
|
B9: 300
|
|
C9: =B9*12
|
|
D9 %: =C9/$C$11
|
|
|
|
A11: Total charges
|
|
B11: =SUM(B4:B9)
|
|
C11: =SUM(C4:C9)
|
|
D11 %: =SUM(D4:D9)
|
|
|
|
A12: Revenus net
|
|
B12: 2600
|
|
C12: =B12*12
|
|
D12 %: =B12/$B$12
|
|
|
|
A13: Reste a vivre
|
|
B13: =B12-B11
|
|
C13: =C12-C11
|
|
D13 %: =B13/B12
|
|
|
|
A15: Epargne sur 12 mois
|
|
B15: =C9
|
|
A16: Objectif epargne
|
|
B16: 3600
|
|
C16: =IF(B15>=B16,"atteint","a revoir")
|
|
|
|
A18: Moyenne par poste
|
|
B18: =ROUND(AVG(B4:B9),2)
|
|
A19: Poste le plus lourd
|
|
B19: =MAX(B4:B9)
|
|
A20: Nombre de postes
|
|
B20: =COUNT(B4:B9)
|
|
A21: Part epargne
|
|
B21 %: =B9/B12
|
|
]]
|
|
|
|
M.ventes = [[
|
|
# Ventes : texte, concatenation et comparaisons.
|
|
A1: Ventes par region
|
|
A3: Region
|
|
B3: Ventes
|
|
C3: Objectif
|
|
D3: Taux
|
|
E3: Statut
|
|
|
|
A4: Nord
|
|
B4: 12500
|
|
C4: 11000
|
|
D4 %: =B4/C4
|
|
E4: =IF(D4>=1,"ok","alerte")
|
|
|
|
A5: Sud
|
|
B5: 9800
|
|
C5: 11000
|
|
D5 %: =B5/C5
|
|
E5: =IF(D5>=1,"ok","alerte")
|
|
|
|
A6: Est
|
|
B6: 14300
|
|
C6: 12000
|
|
D6 %: =B6/C6
|
|
E6: =IF(D6>=1,"ok","alerte")
|
|
|
|
A7: Ouest
|
|
B7: 7400
|
|
C7: 9000
|
|
D7 %: =B7/C7
|
|
E7: =IF(D7>=1,"ok","alerte")
|
|
|
|
A9: Total
|
|
B9: =SUM(B4:B7)
|
|
C9: =SUM(C4:C7)
|
|
D9 %: =B9/C9
|
|
E9: =CONCAT("total ", B9, " / ", C9)
|
|
|
|
A11: Meilleure region
|
|
B11: =MAX(B4:B7)
|
|
A12: Taux median
|
|
B12 %: =ROUND(MEDIAN(D4:D7),3)
|
|
A13: Etiquette
|
|
B13: ="Taux global " & ROUND(D9,2)
|
|
]]
|
|
|
|
M.errors = [[
|
|
# Une feuille qui casse volontairement, pour montrer les codes d'erreur.
|
|
A1: =A1+1
|
|
B1: =1/0
|
|
C1: =NOPE(1)
|
|
D1: =1+"abc"
|
|
E1: =SUM(
|
|
F1: =A1+B1
|
|
G1: =Z9+1
|
|
]]
|
|
|
|
return M
|