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 = @"";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
Thanks in advance
Karthik.k

Sophia CarterPosted May 7, 2025, 8:04 AM
To change the font size for the Excel export data in the provided code snippet, you can modify the style section within the `";
Update the `style` string to include the font size property. For example, to set the font size to 12px, you can modify the line as follows:
By adding the `font-size` property within the `