is there any possibility to export charts done with hightcharts in powerpoint?else can someone help me to find a solution?
Thanx
is there any possibility to export charts done with hightcharts in powerpoint?else can someone help me to find a solution?
Thanx
On
I know this is old but I am currently trying to achieve the same thing. If you are happy to use png or jpg then I would go with phantonJS (OpenQA.Selenium.PhantomJS) to extract an svg and then any conversion mechanism to convert to png/jpg
public IList<string> ExtractSVGs(string htmlFilePath)
{
IList<string> SVGs = new List<string>();
foreach (string chart in getChartIds(htmlFilePath))
{
SVGs.Add(ExtractSVG(htmlFilePath, chart));
}
return SVGs;
}
private IList<string> getChartIds(string htmlFilePath)
{
IList<string> chartIds = new List<string>();
string whatToFind = @" ""renderTo"": """;
foreach (string line in (System.IO.File.ReadLines(htmlFilePath)))
{
if (line.StartsWith(whatToFind))
chartIds.Add("chart" + line.Substring(line.IndexOf(whatToFind) + whatToFind.Length, 32));
}
return chartIds;
}
private string ExtractSVG(string htmlFilePath, string chartId)
{
var driverService = PhantomJSDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
driverService.LoadImages = true;
driverService.ProxyType = "none";
driverService.LocalToRemoteUrlAccess = true;
driverService.WebSecurity = false; // may not be necessary
using (var driver = new PhantomJSDriver(driverService))
{
driver.Navigate().GoToUrl(new Uri("file:///" + htmlFilePath));
string svg = (string)driver.ExecuteScript(String.Format("return {0}.getSVG();", chartId), null);
driver.Close();
return svg;
}
}
You could alter the JS to export directly to png but that would require linking into an export server (or having that code run locally as well).
On a side note you may need to alter the what to find depending on how you build up your html files.
Just export it to an image (PNG or JPG) and add that image to a powerpoint slide? Most highcharts graphs have a download (export) button in the upper right corner of the chart.