Click here to Skip to main content
15,746,102 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I am using Google Chart in a web Application. I want to export Google Chart in Excel. Google Chart Provides Image Data as data:image/png followed by coded string (“data:image/png;base64,iVBO…” ). It is easily rendered in HTML and PDF(using JsPDF ) but not working in excel export using html. Please Assist me.

1 solution

I have resolved it. For Image URI Data base64, saved in a file and then called the file as usual to export in excel.

To Save File:

public string CreateImage(string data)
string fname = Server.MapPath("data-image") + "//chart.png";
var base64Data = Regex.Match(data, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value;
var binData = Convert.FromBase64String(base64Data);
using (var stream = new MemoryStream(binData))
System.Drawing.Bitmap img = new Bitmap(stream);
img.Save(fname, System.Drawing.Imaging.ImageFormat.Png);
return fname;

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900