我需要将listview下载为excel文件。我使用以下代码
public static void ExportListViewAsExcel(Page currentPage, ListView lstviewControlId, string excelName)
{
string str = "attachment; filename=" + excelName + "-" + DateTime.Now.ToString("dd_MM_yyyy_hh_mm_tt") + ".xls";
currentPage.Response.ClearContent();
currentPage.Response.AddHeader("content-disposition", str);
currentPage.Response.ContentType = "application/ms-excel";
StringWriter writer = new StringWriter();
HtmlTextWriter writer2 = new HtmlTextWriter(writer);
HtmlForm child = new HtmlForm();
lstviewControlId.Parent.Controls.Add(child);
child.Attributes["runat"] = "server";
child.Controls.Add(lstviewControlId);
child.RenderControl(writer2);
currentPage.Response.Write(writer.ToString());
currentPage.Response.End();
}
成功出口。但是打开它时,它不包含边框。它完全白色背景。
我之前有零位的16位银行账号。它表明科学。我需要显示这个,因为它是0之前的16位数字。
如何实现它。帮帮我