SoFunction
Updated on 2025-04-04

How to export tables in v-for

1. The following dependencies need to be installed

 npm install -S file-saver xlsx
 npm install -D script-loader

2. Create a new folder in the project: (vendor------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Place two files and .

3. In .vue file

Write these two methods: where list is the content of the table

//export2Excel is the method name you click to export and bindexport2Excel() {
([], () => {
const { export_json_to_excel } = require('../../vendor/Export2Excel');//You should also pay attention to your own path.const tHeader = ['Serial number', 'IMSI', 'MSISDN', 'Dict number', 'Name'];//The name of the header of the tableconst filterVal = ['ID', 'imsi', 'msisdn', 'address', 'name'];//The corresponding content names must be one by oneconst list = ;//tableData is the data name bound to your form, it must correspond toconst data = (filterVal, list);
export_json_to_excel(tHeader, data, 'List excel');// List Excel is the name of the table after exporting, change it yourself as needed})
},
formatJson(filterVal, jsonData) {
return (v => (j => v[j]))
}

Summarize

The above is the editor’s introduction to how to export the tables in v-for. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!