File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 2525 default () {
2626 return {};
2727 }
28- }
28+ },
29+ filename: {
30+ type: String ,
31+ default: ' vue-json2-excel'
32+ },
2933 },
3034 name: " Json2Excel" ,
3135 data () {
3236 return {
3337 workBook: {},
34- workSheet: {}
38+ workSheet: {},
39+ counter: 0 ,
3540 }
3641 },
3742 methods: {
3843 init () {
44+ this .workBook = {};
45+ this .workSheet = {};
3946 this .workBook = xlsx .utils .book_new ();
4047 },
4148 makeDetails () {
8693
8794 },
8895 makeExport () {
89- this .workBook .SheetNames .push (' test' );
96+ let name = ` ${ this .filename }${ this .counter ? ' (' + this .counter ++ + ' )' : ' ' } ` ;
97+ this .workBook .SheetNames = [name];
9098 this .workBook .Sheets .test = this .workSheet ;
9199
92- xlsx .writeFile (this .workBook , ' test .xlsx' );
100+ xlsx .writeFile (this .workBook , ` ${ name } .xlsx` );
93101 },
94102 exportToExcel () {
103+ this .init ();
95104 this .makeDetails ();
96105 this .makeHeader ();
97106 this .makeData ();
98107 this .makeRange ();
99108 this .makeExport ();
100109 }
101110 },
102- created () {
103- this .init ();
104- },
105111 }
106112 </script >
107113
108114<style scoped>
109- .main :hover {
115+ .main :hover {
110116 cursor : pointer ;
111117 }
112118 </style >
You can’t perform that action at this time.
0 commit comments