title: Excelljs - how to create a sheet from stream
body: <p>I am using <a href="https://www.npmjs.com/package/exceljs#reading-xlsx" rel="nofollow noreferrer">ExcellJS</a> library for manipulating Excell on Node.js(Hapi.js).</p>
  <p>I got it to create worksheet based on the file that is uploaded. I did something like this:</p>
  <pre><code>uploadItems: function (request, reply) {
      var data = request.payload;
      if (data.file) {
          var name = data.file.hapi.filename;
          //var path = __dirname + &quot;/uploads/&quot; + name;
          var path = process.cwd() + &quot;/uploads/&quot; + name;
          var file = fs.createWriteStream(path);
  
           data.file.on('end', function (err) {
          var workbook = new Excel.Workbook();
          var bulkParts = [];
          workbook.xlsx.readFile(path)
              .then(function (workbook) {
                  workbook.eachSheet(function (worksheet, sheetId) {
                      worksheet.eachRow({includeEmpty: true}, function (row, rowNumber) {
                          var singleItem = new _Items(data.ProductId, row.values[1], row.values[2]);
                          bulkParts.push(singleItem);
                          console.log(&quot;Row &quot; + rowNumber + &quot; = &quot; + JSON.stringify(row.values));
                      });
                  });
          file.on('error', function (err) {
              console.error(err)
          });
          data.file.pipe(file);
      }
           ...
  </code></pre>
  <p>This works. This method creates a file from stream, and then I read this file and create my object. I would rather create a file directly from the stream, thus avoiding creation on the disk.</p>
  <p><a href="https://www.npmjs.com/package/exceljs#reading-xlsx" rel="nofollow noreferrer">Documentation</a> of the Excell Plugin mentions this:</p>
  <pre><code>// pipe from stream 
  var workbook = new Excel.Workbook();
  stream.pipe(workbook.xlsx.createInputStream());
  </code></pre>
  <p>But honestly I tried many ways, and just cant get it to creat object from stream.
  Any help is appreciated.</p>