Props
| Name | Type | Default | Description |
|---|---|---|---|
data | Array | Data to be exported. | |
fields | Object | Fields inside the JSON objects to export, as { 'Column label': 'path.to.value' }. If none are provided, every property is exported. See Callbacks for formatting. | |
export-fields | Object | Same as fields. Use it when another library (e.g. vee-validate) already uses a fields attribute. | |
type | String | xls | File type: xls, xlsx or csv. |
name | String | data.xls | File name of the download. |
header | String | Array | Title row(s) above the data. A string for one title, an array of strings for several. | |
title deprecated | String | Array | Same as header, kept for backwards compatibility. Avoid it: it conflicts with the HTML title attribute. | |
per-columns-headers | Array | One header per column, e.g. ['Col A', , 'Col C']. | |
footer | String | Array | Footer row(s) below the data. A string for one footer, an array of strings for several. | |
default-value | String | '' | Fallback used when a row has no value for a field. |
worksheet | String | Sheet1 | Name of the worksheet tab. |
meta | Array | [] | Extra <meta> tags for the xls file, e.g. [[{ key: 'charset', value: 'utf-8' }]]. |
fetch | Function | Callback that returns the data when the user clicks. Only used when no data is set. See Fetch data on demand. | |
before-generate | Function | Called right before the data is fetched / generated, e.g. to show a loader. | |
before-finish | Function | Called right before the download dialog opens, e.g. to hide a loader. | |
formats | Object | {} | xlsx only. Cell number formats keyed by column letter, e.g. { B: '0.00%' }. See Cell formats. |
widths | Object | {} | xlsx only. Column widths in characters keyed by column letter, e.g. { A: 20 }. 1.0.26+ |
stringify-long-num | Boolean | false | Stringify long numbers and decimals so they don't lose precision. |
escape-csv | Boolean | true | Wraps every CSV value in =" and " to stop Excel mangling number-like fields. Set to false to disable. |
emit-blob | Boolean | false | Emit the generated file as a blob event instead of downloading it. |
debounce | Number | 500 | Debounce delay (ms) of the download click. |
rtl | Boolean | false | Right-to-left worksheet. |
Events
| Name | Payload | Description |
|---|---|---|
blob | Blob | Emitted with the generated file when emit-blob is true. |
vue
<JsonExcel :data="data" type="xlsx" emit-blob @blob="(file) => upload(file)">
Upload as Excel
</JsonExcel>