excel

Docs › Web component

The <excel-82> web component: attributes and events

Attributes, JS properties and methods, states, events, CSS variables and ::part() of the drag-and-drop form component.

<excel-82> is a web component with a drop zone and file button, a summary (name, format, columns, rows), a pass/fail badge, the list of errors and warnings, a preview table, a template download and an upload progress bar. It uses Shadow DOM, works with the keyboard and announces results with aria-live.

<excel-82 headers="Name,Phone,Amount" min-rows="1" accept="xlsx,xls,csv"
          preview-rows="5" template-download="xlsx"></excel-82>

Attributes

Changing a rule attribute re-checks the file already chosen.

AttributeMeaning
headersExpected headers, comma separated or a JSON array. Order matters; compared after NFC normalization
columnsNumber of columns
min-rows, max-rowsRange for the number of data rows
sheetSheet name or zero-based index (default: the first sheet)
header-rowHeader row number (1-based, default 1)
acceptAllowed formats, comma separated from xlsx,xls,csv
max-sizeMaximum size in bytes (default 52428800 = 50 MB)
strict-warningsTreat warnings (personal data, macros, hidden content, merged headers, extension mismatch, ragged rows, duplicate headers, cell errors) as errors
templateURL of a template file; header and column rules come from it. Attribute rules win when both are given
localeen (default), ko
preview-rowsPreview rows (default 5, 0 hides the preview)
template-downloadcsv or xlsx: shows a template download button (when headers is set)
name, required, disabledForm integration
uploadURL to upload to. No upload without it
upload-asfile (default, multipart) or json ({ fileName, sheet, columns, rows })
upload-fieldMultipart field name (default file)
upload-autoDefault true. With false, the upload runs on form submit and the form is submitted again
telemetryoff turns off usage statistics

JS properties and methods

.file, .result (the check result), .info (the inspect result), .state, .rules (set from JS to replace the attribute rules), .uploadResponse, .check(file), .upload(), .reset(), and for form validation .form, .validity, .validationMessage, .checkValidity(), .reportValidity().

const x = document.querySelector('excel-82');
x.addEventListener('check', (e) => {
  console.log(e.detail.ok, e.detail.errors);   // the check result
});
x.rules = { headers: ['Name', 'Amount'], rows: { min: 1 } }; // replaces the attribute rules
await x.check(file);   // check a file from code
x.reset();

States

idle → checking → invalid | valid → uploading → uploaded | uploadfailed. Form submission is blocked when required has no file, and in the invalid, uploading and uploadfailed states. More in Upload and forms.

Events

All of them bubble and are composed.

EventWhendetail
checkA check finishedThe check result
beforeuploadRight before an upload (cancel with preventDefault()){ file, init }; put auth headers in init.headers
uploadprogressDuring the upload{ loaded, total }
uploadedUpload finished{ status, response }
uploaderrorUpload failed{ status?, error }

Styling

CSS variables --e82-accent, --e82-error, --e82-warn, --e82-bg, --e82-fg, --e82-border, --e82-radius. It follows dark mode (prefers-color-scheme).

::part(): drop, label, choose, input, summary, status, issues, preview, template, progress, retry, notice.

excel-82 { --e82-accent: #0b5fff; --e82-radius: 12px; }
excel-82::part(drop) { padding: 32px; }