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

1 Answer 1

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);

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.