日期:2014-05-18  浏览次数:20442 次

asp.net2.0数据导出,应该数据引用?
用asp.net2.0,将数据从sql导出到excel中,应该如何引用?
另:为什么执行命令dcomcnfg命令后选择cexel后,点击其属性,弹出:
操作完毕?

------解决方案--------------------
ds = new DataSet();
ds = FEGCRM.Access.OrderDA.Execl1();
//以上是数据源
DataTable dt = ds.Tables[ "Product "];
dt.Columns[ "DocNum "].ColumnName = "Excel列名1 ";
dt.Columns[ "LineNum "].ColumnName = "Excel列名2 ";
dt.Columns[ "SN "].ColumnName = "Excel列名3 ";
dt.Columns[ "CardName "].ColumnName = "Excel列名4 ";
dt.Columns[ "ItemCode "].ColumnName = "Excel列名5 ";
StringWriter sw = new StringWriter();
GridView dv = new GridView();
dv.DataSource = dt;
dv.DataBind();
dv.AllowPaging = false;

Response.ClearContent();
Response.Charset = "GB2312 ";
Response.AppendHeader( "Content-Disposition ", "attachment;filename=MyExcelFile.xls ");
// 如果设置为 GetEncoding( "GB2312 ");导出的文件将会出现乱码!!!
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/excel ";

HtmlTextWriter htw = new HtmlTextWriter(sw);

dv.RenderControl(htw);

Response.Write(sw.ToString());
Response.End();
------解决方案--------------------
up........
------解决方案--------------------
一、看看项目中是否引用了组件
二、看看文件中是否using了命名空间
------解决方案--------------------
不喜欢猜测~