This recipe describes how to export a filtered subset of samples 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 exactly the samples currently shown in the grid after filters have been applied — ready for downstream processing outside the LIMS.
/samples page)..csv files (Excel, LibreOffice Calc, Google Sheets, etc.)./samples) from the side navigation.receivedDate, dueDate).RECEIVED, IN_PROGRESS, REPORT_READY, SUBCONTRACTED).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.
The CSV button calls the fetchAndExportCsv helper (libs/utils/src/lib/csv-export.ts:82), which re-issues the findAllSamples GraphQL query with take = 0 and skip = 0 — that is, it asks for every row that matches the current filter and sort state, without paging. The wiring lives in apps/agrometrisis/src/app/samples/sample.ts:2946 (onExportCsv()), where the current gridState() (filter text, sort column, sort order) and the allColumns definition are passed in.
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.gridState() at the moment you click the icon. If you change filters mid-export, simply re-click to regenerate the file.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.