Import wizard
A dialog that takes a CSV — or pasted text — sniffs the delimiter, infers types, maps the file's columns onto the grid's, and hands the rows to you.
The parser is Community. Only the dialog is Enterprise. If you are building your own import UI, everything underneath is already in the free package:
import {
parseCsv, sniffDelimiter, importCsv,
autoMapColumns, buildImportPlan, applyImportMapping,
} from '@kanunilabs/datagrid-core';
The dialog
import { EnterpriseDataGrid } from '@kanunilabs/datagrid-react-enterprise';
<EnterpriseDataGrid
licenseKey={key}
dataSource={rows}
rowKey="id"
columns={columns}
onImport={(imported) => setRows((prev) => [...prev, ...imported])}
/>
Defining onImport is what puts the Import… button on the toolbar. Vanilla
takes the same field and adds a programmatic opener:
const grid = createEnterpriseGrid(el, { /* … */ onImport: (rows) => append(rows) });
grid.openImportWizard();
The two steps are 1. Source (file or paste, delimiter, header row) and 2. Map columns (each file column against a grid column, with the inferred type and a sample). There is no third step.
Using the component directly:
import { GridImportWizard } from '@kanunilabs/datagrid-react-enterprise';
<GridImportWizard
open={open}
onClose={() => setOpen(false)}
columnModel={controller.columnModel}
onImport={(rows) => append(rows)}
previewRows={20}
/>
The grid does not touch your data
onImport gives you rows. That is where the grid's involvement ends — inserting,
updating, deduplicating and writing to a server are yours. Nothing is published
on the event bus, and the import does not enter the editing undo stack.
Auto-mapping is deliberately not fuzzy. It tries the exact column id, the
exact headerName, and a normalised comparison (lowercased, spaces/_/-
removed). Amount Paid does not match Amount — a wrong guess in an import is
worse than no guess.
What this does not do
- CSV-family text only. The picker accepts
.csv,.tsv,.txt,text/csv. No XLSX, JSON, XML, clipboard HTML or archives — convert the Excel file first. - No validation step. No per-row error report, no upsert or dedupe, no partial commit, no rollback.
- Type mismatches are shown, not enforced. Values are carried across as
parsed. Types are inferred from the file, not from the target column's
dataType, so mapping a text column onto a number column puts text in the cell. - Dates stay strings. The date branch returns the trimmed string, not a
Date. - The "(N unparsed)" badge is number-only. A malformed date or an unrecognised boolean never produces one.
- Type inference samples the first 200 non-empty values. A column that is
numeric for 200 rows and text after that is inferred as a number, and the rest
become
NaN. - The boolean vocabulary is fixed:
true/false/yes/no/evet/hayırare accepted,true/yes/evetare truthy. No hook to extend or localise it. - Delimiter sniffing tries four candidates — comma, semicolon, tab, pipe — over the first five non-empty rows. No fixed-width, no multi-character delimiters.
- Short rows are padded, long rows are cropped. Missing fields become
nulland are counted in a warning; extra fields beyond the header count are dropped silently. - Two file columns may be mapped to one target. Auto-mapping refuses it, but a user can do it by hand with no warning, and the last mapping wins.
- Going Back re-parses and resets the mapping. Manual corrections made in step 2 are lost when the user returns to step 1.
- Everything is read into memory at once.
file.text()then a synchronous parse — no streaming, no worker.previewRowstrims the preview table only. A very large file blocks the main thread. - No programmatic open in React. Toggle the
openprop yourself or use the toolbar button; only vanilla hasopenImportWizard(). Vanilla also allows one dialog at a time — opening the filter builder closes the wizard. - Translation is partial. Field labels come from the dictionary;
1. Source,2. Map columns,First row is a header,Delimiter,Next →,← Back,Import N rowsand the summary line are hardcoded English. The "Not filled by this file:" list prints raw column ids, not header names. - Nothing is imported if nothing maps. The commit button stays disabled — there is no silent half-import.
The licence key must carry the datagrid-editing feature. Without a key the
wizard still runs, watermarked.