a zip archiver for xlsx, support zip64.
npm install xlsx-zipXlsx-Zip is a library that adapts for Office Xlsx Zip format. You can use it to compress xlsx's metadata, but can't extract.
this library is inspired by node-compress-commons and node-zip.
sh
npm i xlsx-zip
`Usage
$3
`javascript
const { XlsxZip } = require('xlsx-zip');
const fs = require('fs');async function main() {
// don't set
stream parameter
const xlsxZip = new XlsxZip(); const dirPath = 'directory/path';
// add by directory
await xlsxZip.addDirectory(null, dirPath);
// add by Buffer
await xlsxZip.add('entry/path1', Buffer.from('entry'));
// add by Buffer list
await xlsxZip.add('entry/path1', [Buffer.from('entry')]);
// add by file stream
const rs = fs.createReadStream('file/path');
await xlsxZip.add('entry/path2', rs);
const buf = await xlsxZip.finish();
fs.writeFileSync('./output.xlsx', buf);
}
`$3
`javascript
const { XlsxZip } = require('xlsx-zip');
const fs = require('fs');async function main() {
const stream = fs.createWriteStream('./output.xlsx');
const xlsxZip = new XlsxZip({ stream });
stream.on('close', () => {
console.log('done');
});
const dirPath = 'directory/path';
// add by directory
await xlsxZip.addDirectory(null, dirPath);
// add by Buffer
await xlsxZip.add('entry/path1', Buffer.from('entry'));
// add by Buffer list
await xlsxZip.add('entry/path1', [Buffer.from('entry')]);
// add by file stream
const rs = fs.createReadStream('file/path');
await xlsxZip.add('entry/path2', rs);
await xlsxZip.finish();
}
`$3
you can filter some path you don't want to add into ZIP stream with regExp parameter
`javascript
const { XlsxZip } = require('xlsx-zip');
const fs = require('fs');async function main() {
const xlsxZip = new XlsxZip({
regExp: '.DS_Store'
});
// or
const xlsxZip = new XlsxZip({
regExp: new RegExp('.DS_Store')
});
const dirPath = 'directory/path';
// add by directory
await xlsxZip.addDirectory(null, dirPath);
const buf = await xlsxZip.finish();
fs.writeFileSync('./output.xlsx', buf);
}
``