deno.land / x / sheetjs@v0.18.3 / demos / function / mcstream.js
1234567891011121314151617181920212223/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com *//* eslint-env node */// cat file.xlsx | curl --header 'content-type: application/octet-stream' --data-binary @- "http://localhost:3000/"const XLSX = require('xlsx');
const process_RS = (stream, cb) => { var buffers = []; stream.on('data', function(data) { buffers.push(data); }); stream.on('end', function() { var buffer = Buffer.concat(buffers); var workbook = XLSX.read(buffer, {type:"buffer"}); cb(workbook); });};
module.exports = (hook) => { process_RS(hook.req, (wb) => { hook.res.writeHead(200, { 'Content-Type': 'text/csv' }); const stream = XLSX.stream.to_csv(wb.Sheets[wb.SheetNames[0]]); stream.pipe(hook.res); });};
Version Info