sagar Bhosale

sagar Bhosale

  • NA
  • 179
  • 176k

How to resduced size of excel exported in asp.net

Dec 12 2011 11:30 PM
Hi friends,

I want to reduced size of exported excel .
I have written code below i got 7mb  size of excel sheet .when i copy same data of exported excel to new excel sheet i got size of new excel is upto 1mb.

Plz Help me how to reduce excel size..

protected void LinkBtnExcell_Click(object sender, EventArgs e)
  {
  DataSet ds = new DataSet();
  ds = ObjMFBack.Get_BrokerageSlabStructure();
  GridView gvExport = new GridView();
  gvExport.DataSource = ds;
  gvExport.DataBind();
  Response.Clear();
  Response.Buffer = true;
  Response.Charset = "";
  Response.ClearContent();
 
  Page.EnableViewState = false;
 
  Response.ContentType = "application/ms-excel";
  Response.AddHeader("Content-Disposition", "inline;filename=BrokerageSlabStructureFormat.xls");

  System.IO.StringWriter stringWriter = new System.IO.StringWriter();
  HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
  gvExport.HeaderRow.Style.Add("background-color", "#99ccff");
  System.IO.StringWriter sw = new System.IO.StringWriter();
  HtmlTextWriter htw = new HtmlTextWriter(sw);
  gvExport.RenderControl(htw);

  //scrollUserTable.RenderControl(htw);
  Response.Write(sw.ToString());
  Response.End();
  Response.Flush();
 
  }