Jump to content
Software FX Community

chart missing when exporting to the excel


kurkure
 Share

Recommended Posts

  • 2 weeks later...

I used this to export as excel format, HTH private void ExportToExcel(string strFileName, DataView dv)

{

Response.ClearContent();

Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);

Response.ContentType =

"application/excel";System.IO.StringWriter sw = new System.IO.StringWriter();

HtmlTextWriter htw = new HtmlTextWriter(sw);

//Instantiate a datagridSystem.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();

dg.DataSource = dv;

dg.DataBind();

//Tell the datagrid to render itself to htmltextwriter

dg.RenderControl(htw);

Response.Write(sw.ToString());

Response.End();

}

Link to comment
Share on other sites

Hi,

 Thanks for the additional info. Unfortunately, I don't believe this approach will work with Chart FX.

While the DataGrid Control ultimately renders as an HTML table, the generated charts are basically images. The RenderControl call for the chart object returns the HTML that refers to an image on the server.

You may want to work with the Office libraries instead in order to create a new Excel file with an embedded image. I found some information on line that may be of help:

http://vb.net-informations.com/excel-2007/vb.net_excel_2007_insert_picture.htm 

regards,

TT 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...