This recipe describes how to export the samples grid to a CSV file, so you can process it in a spreadsheet for batch analysis, customer reports, or accreditation submissions.
Produce a CSV file that contains the samples matching the free-text search term, in the grid's current sort order — ready for downstream processing outside the LIMS. The filter panel's criteria (status, customer, etc.) only narrow what's shown on screen; see the note below.
/samples page)..csv files (Excel, LibreOffice Calc, Google Sheets, etc.)./samples) from the side navigation.receivedDate — this filters the received date only, not the due date).samples-YYYYMMDD-HHmmss.csv. Open it in your spreadsheet of choice.The exported columns are exactly those you have marked as visible via the column configuration — hidden columns and the actions column are skipped. If you need extra fields in the export, surface those columns first via the column-configuration dialog.Important: only the free-text search term and the current sort order carry over into the CSV file. The filter panel's criteria (status, customer, lab method, instrument, date range, SLA, show cancelled) only narrow what's shown on screen — they are not applied to the CSV export. If you need a narrower subset in the file, use the search box.
The CSV button calls the fetchAndExportCsv helper (libs/utils/src/lib/csv-export.ts:102), which re-issues the findAllSamples GraphQL query with take = 0 and skip = 0 — that is, it asks for every row that matches the free-text search term and the current sort order, without paging. The wiring lives in apps/agrometrisis/src/app/samples/sample.ts:2634 (onExportCsv()), where only the current gridState() (filter, sortColumn, sortOrder) and the allColumns definition are passed in. The filter panel's criteria (status, customer, lab method, instrument, dates, SLA, show cancelled) live in a separate filterValues() signal and are not forwarded to this call — that's why they don't affect the CSV file, even though they filter the on-screen grid normally (via #buildFilterExtras(), which the paginated list and the PDF print both use, but the CSV export does not).
The result is serialised to CSV entirely in the browser: visible columns are selected, field values are escaped (" doubled), nested GraphQL relation objects (e.g. contact, labMethod) are resolved to human-readable strings, and ISO timestamps are truncated to YYYY-MM-DD. The file is prefixed with (UTF-8 BOM) so Excel renders Greek characters correctly. No backend storage is involved — the file is built and downloaded purely through Blob + URL.createObjectURL.
YYYY-MM-DD). Excel will recognise them as real dates and let you sort or pivot directly.The same CSV export pattern is wired into every grid page in the app — Contacts, Analyses, Invoices, Instruments, Control samples, Deviations, CAPA, Training records, and more. Each list page exposes the same CSV icon in its title bar, the same filter panel, and the same exportToCsv / fetchAndExportCsv plumbing.
See apps/agrometrisis/src/app/contacts/contact.ts:765 (onExportCsv()) as a parallel example for contacts — the only differences are the GraphQL query name (findAllContacts) and the extras block fed to the service. Once you learn the flow on one grid, you know them all.