# Memory grid export The quick start for Atlas Virtual Grid, and the project behind the [tutorial](https://youseful.software/delphi/atlas-virtual-grid.html#tutorial). A console program that never shows a window: - fills a `TAtlasMemoryData` with six typed columns (number, text, date, yes/no) from invariant text, and shows that a row with a bad value is refused whole; - binds a `TAtlasVirtualGrid`, which creates one column per data column, then sets format masks, bands and count/sum/average totals; - sorts ascending and descending, filters on the formatted text, and checks that totals follow the filter; - edits through the data source and shows the grid following it, including refused values and a read-only column; - copies the selection as tab-separated text; - writes `orders.csv`, `orders.html`, `orders.svg` and `orders.png`. Every step checks its own result and raises on a mismatch, so the exit code is 0 only when everything matched. ## Build and run Open `MemoryGridExport.dpr` in Delphi 13; the IDE creates the project file. Add the Atlas Virtual Grid `src` folder and the Atlas Plot `src` folder to the project's search path, then build and run for Win32 or Win64. No packages need to be installed. The program needs no input. It checks its own results and stops with an error if any of them differs from the output below. ## Expected output ``` 1. Columns and rows ok: 6 rows, 6 columns ok: a row with a value that does not fit its column is rejected whole 2. Bind the grid and describe the columns ok: columns were created from the source ok: cells are formatted per column ok: totals: count 6, quantity sum 27, average price 229.21 3. Sort ok: ascending by customer; equal keys keep source order ok: descending by quantity; the null quantity comes last 4. Filter ok: 2 Fabrikam rows, still sorted ok: totals follow the filter ok: the filter reads the formatted date text: 3 rows shipped before 10 January ok: filter and sort removed 5. Edit through the data source ok: the grid follows the source: sum is now 32 ok: text that is not a number is refused and the value kept ok: the read-only key column refuses writes 6. Selection text ok: tab-separated formatted rows, ready for the clipboard 7. Text output Order,Customer,Shipped,Quantity,Unit price,Paid 1001,Contoso,2026-01-05,4,125.5,true 1002,Fabrikam,2026-01-06,12,40,false 1003,Northwind,2026-01-09,1,980,true 1004,Contoso,2026-01-12,5,125.5,false 1005,"Tailspin, Ltd",2026-01-15,7,64.25,true 1006,Fabrikam,,3,40,true ok: CSV carries raw values: invariant numbers, ISO dates, true/false ok: commas are quoted; nulls are empty ok: hidden columns are left out ok: HTML has the caption, bands and totals 8. Pictures and files ok: SVG of the visible part of the grid ok: orders.csv written to ...\MemoryGridExport ok: orders.html written to ... ok: orders.svg written to ... ok: orders.png written to ... ok: unknown extensions are refused MemoryGridExport: all checks passed ``` `orders.png` shows two band headings (Shipment, Amount), right-aligned numbers and dates, check boxes for the Paid column and a footer with 6, 32 and 229.21. ## Adapting it - Replace the `AddRow` calls with your own data. Values are read with invariant settings (`'.'` decimals, ISO dates, `yes`/`no`); use `SetCell` with `TAtlasCell.OfNumber` and friends when you already have typed values. - The program sets `FormatSettings := TFormatSettings.Invariant` so that its checks hold on every machine. In a real application leave the user's settings alone: the grid's formatted text (`CellText`, HTML, pictures) follows them, while CSV stays invariant. - The pictures draw what would be on screen, starting at `TopRow`. For every row, use CSV or HTML.