I actually got this working once but then I lost the code to do it and haven't been able to get it working again.
I am able to get the file pretty easily using a $.get(server filepath) and it gives me a bunch of crazy looking data...I've tried various methods to read in binary data as a blob and arrayBuffer but none of these have worked right.
how can I convert this into the actual data and then to JSON similar to what D3.parseCSV does?
I've tried the following:
$.ajax({
url: url,
method: 'GET',
dataType: 'binary',
processData: false,
responseType: 'arrayBuffer',
}).then(function (data) {
return data
}, function (error) {
alertify.error('There was an error retriving the data');
});
};
which gives me back the same data as just using $.get(url)
I've tried using Sheets.JS and did
$.get(filePath).then(function(data) {
XLSX.read(data, {Props: {type: "buffer"}})
})
and get a "Unrecognized type [object Object]" error.
If I use type: "binary" I get "undefined TypeError: Cannot read property '0' of undefined"
I've tried manipulating it with the following:
var buf = new ArrayBuffer(csvData.length * 2);
var bufView = new Uint16Array(buf);
for (var j = 0; j < csvData.length; j++) {
bufView[j] = csvData.charCodeAt(j);
}
var myData = buf;
I've tried using decoder("utf-8") and then decoder.decode(csvData)...
haven't gotten anything to work.