Skip to content

Commit 2fda486

Browse files
committed
added method "customizeZip" to let the developer customise the final zip (XLSX) file content if they want to before it is generated and sent to the browser
1 parent 7343b58 commit 2fda486

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

js/buttons.html5.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,12 @@ DataTable.ext.buttons.excelHtml5 = {
13851385
filename = filename.substr(0, 175);
13861386
}
13871387

1388+
// Let the developer customize the final zip file if they want to before it is generated and sent to the browser
1389+
if (config.customizeZip) {
1390+
config.customizeZip(zip, data, filename);
1391+
}
1392+
1393+
13881394
if (zip.generateAsync) {
13891395
// JSZip 3+
13901396
zip.generateAsync(zipConfig).then(function (blob) {

js/dataTables.buttons.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2564,7 +2564,8 @@ var _exportData = function (dt, inOpts) {
25642564
return Buttons.stripData(d, config);
25652565
}
25662566
},
2567-
customizeData: null
2567+
customizeData: null,
2568+
customizeZip: null
25682569
},
25692570
inOpts
25702571
);

types/types.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,11 @@ declare module 'datatables.net' {
555555
*/
556556
customizeData?: FunctionButtonCustomizeData;
557557

558+
/**
559+
* EXCEL
560+
*/
561+
customizeZip?: FunctionButtonCustomizeZip;
562+
558563
/**
559564
* PDF: portrait / landscape
560565
*/
@@ -629,4 +634,6 @@ declare module 'datatables.net' {
629634
type FunctionButtonCustomizeData = (content: any) => void;
630635

631636
type FunctionButtonColvisColumnText = (dt: Api<any>, i: number, title: string) => string;
637+
638+
type FunctionButtonCustomizeZip = (zip: any, data: ButtonsApiExportDataReturn, filename: string) => void;
632639
}

0 commit comments

Comments
 (0)