I need to save object HTMLImageElement in excel file. I am using highchart and get the image of the chart by getSVG method (Overall process in [http://willkoehler.net/2014/11/07/client-side-solution-for-downloading-highcharts-charts-as-images.html][1])
Now i am trying to write this image into excel file. for doing that i need to pass the image by webservice but i am stuck into overall process. what i have tried is the following:
var svg = chart.getSVG({
exporting: {
sourceWidth: chart.chartWidth,
sourceHeight: chart.chartHeight
}
});
var canvas = document.createElement('canvas');
canvas.height = render_height;
canvas.width = render_width;
var image = new Image;
image.onload = function () {
canvas.getContext('2d').drawImage(this, 0, 0, render_width, render_height);
var data = canvas.toDataURL("image/png")
download(data, filename + '.png');
};
var dataitem= JSON.stringify({ data: image});
$.ajax({
type: "POST",
contentType: "application/json;charset=utf-8",
datatype: "json",
data: dataitem,
url: "FrontDesign/Sendimage",
success: function (data) {
//code for success
}
});
I know JSON.stringify({ data: image}) is not process to pass. Any Suggestion regarding this matter?