C# – 从Oracle DB到Excel的查询 – 包括多余的标题行

使用C#编写.NET 4.0应用程序。

从Oracle数据库检索数据集。 当复制到HTML页面时,DataSet显示正常。 导出到MS Excel 2010时,工作表中有几个图标无法删除(请参阅图像)。 数据上方还有几行来自网页的HTML。 我不明白为什么这些行被添加到工作表中。

Excel电子表格中的图标

这是在Excel中打开DataSet的代码。

if (ds.Tables[0].Rows.Count > 0) { this.dgAtpInfo.Attributes.Add("width", "95%"); this.dgAtpInfo.DataSource = ds; this.dgAtpInfo.DataBind(); Response.Clear(); Response.Buffer = true; Response.ClearContent(); Response.AddHeader("Content-Type", "application/vnd.ms-excel"); Response.Charset = ""; this.EnableViewState = false; } else { Response.Write("No Data Found."); Response.Write(System.DateTime.Now); Response.End(); } 

TIA