Javascript Chart to Excel
Hi I'm using highcharts to create some charts (pie, bar, etc...) using just Javascript. These charts do not use Flash or anything like that. Is it possible for me to convert the resulting HTML page with the Javascript chart开发者_StackOverflow中文版 to an excel document that properly shows the image?
I've tried the standard change mime types for excel and so far I've only been able to export an HTML table on the page, but no chart.
You could take a screenshot of the page, crop it, and insert the picture into Excel :)
You could create a sample chart in excel and export it as a HTML page. Look at the result to see if/how excel stores the graph in HTML.
In any case, here's the Microsoft Office HTML and XML Reference
If your chart is in a div, try this
var imgObj = document.getElementById('yourdivname');
imgObj.contentEditable = 'true';
var controlRange;
if (document.body.createControlRange)
{
controlRange = document.body.createControlRange();
controlRange.addElement(imgObj);
controlRange.execCommand('Copy');
var objExcel = new ActiveXObject ("Excel.Application");
objExcel.visible = true;
var objWorkbook = objExcel.Workbooks.Add;
var objWorksheet = objWorkbook.Worksheets(1);
objWorksheet.Paste;
}
精彩评论