protected void btn_excel_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=SOPRODI_VEND_CLIE_" + DateTime.Now.ToShortDateString() + ".xls"); Response.Charset = ""; // If you want the option to open the Excel file without saving than // comment out the line below Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); G_INFORME_TOTAL_VENDEDOR.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); }
protected void btn_excel_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=SOPRODI_VEND_CLIE_" + DateTime.Now.ToShortDateString() + ".xls"); Response.Charset = ""; // If you want the option to open the Excel file without saving than // comment out the line below Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); string HTML_EXCEL = "<label> TASA CAMBIO: " + tx_dolar.Text + " </label> - <label> " + CB_TIPO_DOC_GRILLA.SelectedItem.ToString() + " </label> <label> " + TX_AÑO.Text + " </label>"; HTML_EXCEL += ""; //HTML += "</div>"; R_Excel_1.InnerHtml = HTML_EXCEL; R_Excel_1.RenderControl(htmlWrite); G_INFORME_TOTAL_VENDEDOR.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); }