我的导出代码如下: 请大神们救救 我
private void Export(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
ListView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
------最佳解决方案--------------------------------------------------------
用 MyXls 这个控件导吧 很简单的
string filename = "预付保费网银" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_sssss") + ".xls";
XlsDocument xls = new XlsDocument();
xls.FileName = filename;
Worksheet sheet = xls.Workbook.Worksheets.Add("Sheet1");
XF xfdate = xls.NewXF();
xfdate.Format = StandardFormats.Decimal_2;
Cells cells = sheet.Cells;
cells.Add(1, 1, "文件类型"); cells.Add(1, 2, "ExtPayBatch");
cells.Add(2, 1, "标题"); cells.Add(2, 2, "支付转账经办");
string[] titl = { "付款账号", "币种", "本/他行标志", "收款单位编号", "收款人账号", "收款人名称", "支付联行号", "开户网点名称", "开户地所在省/市/自治区", "开户地所在市/县", "支付方式", "支付金额", "预约支付标志", "预约支付日期", "预约支付时间", "摘要", "取票人证件种类", "取票人号码", "取票人姓名", "备注" };
for (int i = 0; i < titl.Length; i++)
{
cells.Add(4, i + 1, titl[i]);
}
string sql = "select fk_zh,sk_zh,sk_name,sk_hh,sk_kh,fee_pay from yfbf_fk where id in (" + ids + ")";
DataTable dt = DBUtility.DbHelperOra.Query(sql).Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)