- I am trying to read the content of a
csv
file by taking an input in an Microsoft Office Excel add-in
.
- Facing the error as
taskpane.js:84 TypeError: Failed to execute 'readAsText' on 'FileReader': parameter 1 is not of type 'Blob'.
- HTML
<form>
<input type="file" id="csv-file">
<button type="submit" id="csv-data">Submit</button>
</form>
async function import_from_csv() {
try {
var file = document.getElementById("csv-file");
var files = file[0];
var reader = new FileReader();
reader.readAsText(files);
reader.onload = function (event) {
var csv = event.target.result;
var data = $.csv.toArrays(csv);
console.log("Data =", data);
};
} catch (error) {
console.error(error);
}
}