Skip to content

Commit

Permalink
New: Added method "customizeZip" to let the developer customise the f…
Browse files Browse the repository at this point in the history
…inal zip (XLSX) file content

Merge pull request #200 from alesak/master
  • Loading branch information
AllanJard authored Mar 11, 2024
2 parents 7343b58 + 2fda486 commit cfffd42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions js/buttons.html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,12 @@ DataTable.ext.buttons.excelHtml5 = {
filename = filename.substr(0, 175);
}

// Let the developer customize the final zip file if they want to before it is generated and sent to the browser
if (config.customizeZip) {
config.customizeZip(zip, data, filename);
}


if (zip.generateAsync) {
// JSZip 3+
zip.generateAsync(zipConfig).then(function (blob) {
Expand Down
3 changes: 2 additions & 1 deletion js/dataTables.buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -2564,7 +2564,8 @@ var _exportData = function (dt, inOpts) {
return Buttons.stripData(d, config);
}
},
customizeData: null
customizeData: null,
customizeZip: null
},
inOpts
);
Expand Down
7 changes: 7 additions & 0 deletions types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ declare module 'datatables.net' {
*/
customizeData?: FunctionButtonCustomizeData;

/**
* EXCEL
*/
customizeZip?: FunctionButtonCustomizeZip;

/**
* PDF: portrait / landscape
*/
Expand Down Expand Up @@ -629,4 +634,6 @@ declare module 'datatables.net' {
type FunctionButtonCustomizeData = (content: any) => void;

type FunctionButtonColvisColumnText = (dt: Api<any>, i: number, title: string) => string;

type FunctionButtonCustomizeZip = (zip: any, data: ButtonsApiExportDataReturn, filename: string) => void;
}

0 comments on commit cfffd42

Please sign in to comment.