-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spreadsheet toJSON() does not contain Workbook images info #6411
Labels
Bug
C: Spreadsheet
Dependency
FP: Unplanned
Sync status with associated Feedback Item
jQuery
SEV: Medium
Comments
The images data could be retrieved from the Spreadsheet itself following this logic: function loadBinary(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function () {
callback(xhr.response, xhr.getResponseHeader("Content-Type"));
};
xhr.onerror = function () {
callback(null);
};
xhr.open("GET", url);
xhr.responseType = "arraybuffer";
xhr.send();
}
function next() {
if (--countOfImages <= 0) {
workbook.images = images;
}
}
var images = {};
var spreadsheet = $("#spreadsheet").getKendoSpreadsheet();
var wbImages = spreadsheet._workbook._images;
var keys = Object.keys(wbImages);
var countOfImages = keys.length;
var workbook = spreadsheet.toJSON();
if (countOfImages) {
keys.forEach(function (id) {
var url = wbImages[id].url;
loadBinary(url, function (data, contentType) {
images[id] = { type: contentType, data: data };
next();
});
});
} Or better, retrieve images directly from Blob objects: function next() {
if (--countOfImages <= 0) {
workbook.images = images;
}
}
var images = {};
var spreadsheet = $("#spreadsheet").getKendoSpreadsheet();
var wbImages = spreadsheet._workbook._images;
var keys = Object.keys(wbImages);
var countOfImages = keys.length;
var workbook = spreadsheet.toJSON();
if (countOfImages) {
keys.forEach(function (id) {
var blob = wbImages[id].blob;
var contentType = blob.type;
blob.arrayBuffer().then((buffer) => {
images[id] = { type: contentType, data: buffer };
next();
});
});
} |
Reported in ticket ID: 1520163 |
Related to: #6529 |
Reported in ticket ID: 1551883 |
Reported in ticket ID: 15981 |
Reported in ticket ID: 1608333 |
pepinho24
added
dependencies
Pull requests that update a dependency file
Dependency
and removed
dependencies
Pull requests that update a dependency file
labels
Nov 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug
C: Spreadsheet
Dependency
FP: Unplanned
Sync status with associated Feedback Item
jQuery
SEV: Medium
Bug report
Spreadsheet toJSON() does not contain Workbook images info. As a consequence, the
e.workbook
parameter in theexcelExport
event does not containimages
info, even if itssheets
havedrawings
.Reproduction of the problem
Call
spreadsheet.toJSON()
on a Spreadsheet that has some images inserted. The JSON definition will not haveimages
even if it hasdrawings
for its sheet(s).Expected/desired behavior
Images info should be present in the exported JSON
Environment
Bug report in Common Engine
The text was updated successfully, but these errors were encountered: