When data comes more than 30 Rows in Grid then the Excel goes in different format.There is parsian/Urdu Font in Grid data.
<div id="PrintDiv">
<asp:GridView ID="gvExamReport" ClientIDMode="Static" runat="server" OnDataBound="gvExamReport_DataBound"
HeaderStyle-Height="20" HeaderStyle-HorizontalAlign="Center" OnRowDataBound="gvExamReport_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="مرتبة">
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#a6f0c0" Height="35" Font-Size="Medium" />
<RowStyle HorizontalAlign="Center" />
</asp:GridView>
<br />
<asp:Button ID="Button1" runat="server" Text="Import To Excel" CssClass="btn btn-primary"
OnClick="Button1_Click" />
</div>
try
{
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvExamReport.AllowPaging = false;
gvExamReport.DataSource = ViewState["datag"];
gvExamReport.DataBind();
gvExamReport.HeaderRow.Style.Add("background-color", "#FFFFFF");
gvExamReport.RenderControl(htw);
Response.Write(sw.ToString());
Response.Flush();
Response.End();
}