Struggling with sending a "large" table using OfficeJS:
functionfile.html loaded from manifest route
<script>
(function (){
"use strict";
Office.initialize = function (reason) {
$(document).ready(function() {
$("#send-data-button").click(send_data);
});
};
function send_data() {
return Excel.run( function(context) {
var data = context.workbook.worksheets.getItem("SheetName")
.getRange("A1:K3673").load("values");
return context.sync().then( function() {
// 2d table is correctly seen
// $("body").append(data.values);
// Just gets lost in ajax call
$.ajax({
type: "GET",
url: mysite,
data: {"accessData": data.values},
}).done( function(success) {
$("body").append("All Done");
}).fail( function(error) {
$("body").append("Error == " + JSON.stringify(error));
});
return context.sync();
});
});
}
})();
</script>
<div> <button id="send-data-button"> Send </button></div>
Trying to send this data, but facing challenges. I have a Flask server handling the request on the backside and was hoping to use pandas.read_json
. However, no matter how I attempt to send it, various errors occur. When evaluating flask.request
with data.values[0][0]
, here's what I get:
CombinedMultiDict([ImmutableMultiDict([('update_date', '43191'), ('accessData', 'Channel')]), ImmutableMultiDict([])])
Furthermore, when evaluating data.values[0]
, I receive an expected list of values:
CombinedMultiDict([ImmutableMultiDict([('update_date', '43191'), ('accessData[]', 'Channel'), ... <All my column headers>, ImmutableMultiDict([])])
But attempting to send the 2D array with just data.values
results in an error message within ajax.fail
:
Error == {"readyState":0,"status":0,"statusText":"error"}
Similarly, trying JSON.stringify(data.values)
yields the same error message:
Error == {"readyState":0,"status":0,"statusText":"error"}
I even attempted converting each column into some kind of nested keys list inside accessData
, but encountered the same error message. Any assistance would be highly appreciated.