0

I am trying to read from a excel file, manipulate and create another excel file from it, i am using stream support for this. Most of it is working fine but i see resultant excel file containing {"sharedString":0} instead of actual values.

Below is my relevant code

let ws = fs.createWriteStream(fpath);
const workbook = new ExcelJS.stream.xlsx.WorkbookWriter({stream: ws, useStyles: true, useSharedStrings: true});
const myworksheet = workbook.addWorksheet('sheet1');
const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader(sheet.path, options);
workbookReader.read();

workbookReader.on('worksheet', worksheet => {
    worksheet.on('row', row => {
        myworksheet.addRow(row.values);
     });
});

workbookReader.on('shared-strings', sharedString => {
    console.log('not coming here');
});

workbookReader.on('end', async () => {
  console.log('processing done...');
  await workbook.commit();
});

Please see the attached file for your reference.

enter image description here

Any help on how to fix this will be really great, Thanks.

opensource-developer
  • 2,826
  • 4
  • 38
  • 88

1 Answers1

1

Once i created the WorkbookReader with below options

const options = {
  sharedStrings: 'cache',
  hyperlinks: 'cache',
  worksheets: 'emit',
  styles: 'cache',
};

it worked!

opensource-developer
  • 2,826
  • 4
  • 38
  • 88