'How to remove <div> when export excel where is no data?
How to remove the <div> tag in Excel when I try to export empty data? When it contains data the <div> tag does not exist, it exists when the data is empty, I want to remove the tag how do I do that?
This is my export code
public void ExportExcel_AccountInfo(string Prmreportdate, string PrmBranch, string prmdrpdown_sort, string PrmWilayah)
{
var sb = new StringBuilder();
string thisDATE = DateTime.Today.ToString("dd/MM/yyyy");
var namafileparam = "Report_Account_Information_Konven_" + thisDATE;
var gv = new GridView();
gv.DataSource = this.GetAccountInfoList(Prmreportdate, PrmBranch, prmdrpdown_sort, PrmWilayah);
gv.DataBind();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename="+namafileparam+".xls");
Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter objStringWriter = new StringWriter();
HtmlTextWriter objHtmlTextWriter = new HtmlTextWriter(objStringWriter);
for (int i = 0; i < gv.Rows.Count; i++)
{
GridViewRow row = gv.Rows[i];
//Apply text style to each Row
gv.Rows[i].Attributes.Add("class", "textmode");
}
gv.RenderControl(objHtmlTextWriter);
Response.Output.Write(objStringWriter.ToString());
Response.Flush();
Response.End();
}
or if data is empty can I add text in excel like "data not found?"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
