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