1
Answer

How to chagne the font size for the Excel Eport data ?

Photo of Karthik K

Karthik K

1d
60
1

How to change the excel export data font size  for the bellow code . 

 

protected void btnExcel_Click(object sender, EventArgs e)
{
    Response.Clear();
    Response.Buffer = true;
    Response.AddHeader("content-disposition",
     "attachment;filename=GridViewExport.xls");
    Response.Charset = "";
    
    Response.ContentType = "application/vnd.ms-excel";
    StringWriter sw = new StringWriter();
    
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    
    for (int i = 0; i < GridView1.Rows.Count; i++)
    {
        //Apply text style to each Row
        GridView1.Rows[i].Attributes.Add("class", "textmode");
    }

    GridView1.RenderControl(hw);
    string style = @"<style> td { mso-number-format:\@; } </style>";
    Response.Write(style);
    Response.Output.Write(sw.ToString());
    Response.Flush();
    Response.End();

}

 

 

Thanks in advance 

Karthik.k 

Answers (1)