4

So I am using Electron with React to create an application, where I want to do some basics Excel operations. Here is my code

import Excel from 'exceljs';

var sheetName = 'Inventory';
var fileName = '../../inventory.xlsx';
var workbook = new Excel.Workbook();

export const createWorkbook = () => {
    workbook.addWorksheet(sheetName);
    workbook.xlsx.writeFile(fileName).then(() => {
        console.log('Excel file created');
    }).catch((error) => {
        console.log(`${error}`);
    });
}

I didn't include the columns and rows function and read as the problem is occurring in this createWorkbook function. This is the code I used in the react component

<button onClick={createWorkbook}>Create an Excel File</button>

I made sure to import it properly and ensure it's working. It's entering into the function, but this is the error I get and it's from the writeFile function I believe.

TypeError: s.createWriteStream is not a function

Rohit V
  • 75
  • 1
  • 5

0 Answers0