0
  • I am simply trying to convert a base-64 string to csv. The file is in CSV format transmitted in base-64 string.
  • I am implementing this in Microsoft Office Excel Addins
  • Code base-64-string
// getting the base-64 string
  let base_64_string = [base-64-string];

  // decode the base-64 string 
  let csvContent = atob(base_64_string);

  // convert the decoded base-64 string to csv
  var blob = new Blob([csvContent], {type: "data:application/octet-stream;base64"});
  • Error
Compiled with problems:

WARNING in ./src/taskpane/taskpane.js 310:17-21

export 'Blob' (imported as 'Blob') was not found in 'buffer' (possible exports: Buffer, INSPECT_MAX_BYTES, SlowBuffer, kMaxLength)
  • Another method here
Lav Sharma
  • 327
  • 1
  • 5
  • 23

1 Answers1

1

The code you've posted is not the problem (as demonstrated by the code snippet below).

// generate a base-64 encoded csv string
const base_64_string = btoa("a,b,c");

// decode the base-64 string 
const csvContent = atob(base_64_string);

// convert the decoded base-64 string to csv
const blob = new Blob([csvContent], {type: "data:application/octet-stream;base64"});

console.log(blob);
Rocky Sims
  • 3,523
  • 1
  • 14
  • 19
  • This works, but while writing the ```csv``` data to ```excel``` it gives the error as ```Uncaught TypeError: e.match is not a function```, using ```XLSX``` functions. – Lav Sharma Aug 16 '22 at 06:09