score:4

Accepted answer
  1. Here is link on highcharts documentation. Thats will help u to export image and store it.

  2. a) Documentation #1
    b) Documentation #2
    That will help u with PHPExcel classs API.

  3. And finally exapmle of image paste to a sheet, using PHPExcel class: one or two;

Have more questions? See that links: one, two.
And official PHPExcel examples: here.

Good luck!

score:0

First you have to send the svgtext and the csv text ti the server via ajax. Then do the following:

public JsonResult ExportToImage(string base64, string graphdata) { try {

            var base64String = base64.Remove(0, 1);
            var rows = graphdata.Split('\n');

        byte[] bytes = Convert.FromBase64String(base64);
        var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory , "Content\\Images\\");
            DirectoryInfo di = new DirectoryInfo(path);
            FileInfo[] files = di.GetFiles("*.xls")
                                 .Where(p => p.Extension == ".xls").ToArray();
            foreach (FileInfo file in files)
                try
                {
                    file.Attributes = FileAttributes.Normal;
                    System.IO.File.Delete(file.FullName);
                }
                catch { }
            using (Image image = Image.FromStream(new MemoryStream(bytes)))
        {
            image.Save(path+"output.png", ImageFormat.Jpeg);  // Or Png
        }

            var xlApp = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbook xlWorkBook = xlApp.Workbooks.Add();
            Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet = xlWorkBook.Sheets[1];

            for(var y=0; y<rows.Count();y++)
            {
                var row = rows[y];
                var columValues = row.Split(',');
                for (var x = 0; x < columValues.Count(); x++)
                {
                    xlWorkSheet.Cells[y+20, x+1] = columValues[x];
                }

            }


            xlWorkSheet.Shapes.AddPicture(path + "output.png", MsoTriState.msoFalse, MsoTriState.msoCTrue, 0, 0, -1, -1);
            var fileName = string.Format("GraphDataExport{0}.xls", DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss"));
            xlWorkBook.SaveAs(path + fileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal);
            xlWorkBook.Close(true);
            xlApp.Quit();

            Marshal.ReleaseComObject(xlApp);
            return Json(fileName);
        }
        catch (Exception e)
        {
            return Json(e.Message + Environment.NewLine + e.InnerException + Environment.NewLine + e.Data + Environment.NewLine);
        }
    }

Now you can do a window.location to that file


Related Query

More Query from same tag