以下是我一段导处excel的代码,导出来数据都是对的,但是更本不是excel只是回缀名是xls因为我把导出的excel在导入的时候会报外部表不是预期的格式这个错误,而我试过,我把导出的excel打开后另存为xls格式在导入就不会报错,或者我自己建一个xls导进去也不会报错,请大家帮帮忙改动以下代码,怎么样改才能导出来的是真正的excel表。
protected void Button2_Click(object sender, EventArgs e)
{
ds = new DataSet();
SqlConnection con = new SqlConnection( "Data Source=10.17.8.7;Initial Catalog=CRMOPSC;User ID=sa;Password=password ");
SqlDataAdapter da = new SqlDataAdapter( "Select Id,LotNo,Enterprise,CardName,CardCode,NameCode,Demand,DeliveryDate,Mark,Height,Width,Length,Weight,Summation,R,Increase_Decrease,Memo,TWFH,Single_Storage,Sum_Storage,Grade,S16,S12,S9,S5,S4,S2 From Alan ", con);
da.Fill(ds, "Alan ");
DataTable dt = ds.Tables[ "Alan "];
dt.Columns[ "Id "].ColumnName = "ID ";
dt.Columns[ "LotNo "].ColumnName = "订单批号 ";
dt.Columns[ "Enterprise "].ColumnName = "业 ";
dt.Columns[ "CardName "].ColumnName = "客户 ";
dt.Columns[ "CardCode "].ColumnName = "单号 ";
dt.Columns[ "NameCode "].ColumnName = "客户编号 ";
dt.Columns[ "Demand "].ColumnName = "需求 ";
dt.Columns[ "DeliveryDate "].ColumnName = "交期 ";
dt.Columns[ "Mark "].ColumnName = "料 ";
dt.Columns[ "Height "].ColumnName = "厚 ";
dt.Columns[ "Width "].ColumnName = "宽 ";
dt.Columns[ "Length "].ColumnName = "长 ";
dt.Columns[ "Weight "].ColumnName = "重 ";
dt.Columns[ "Summation "].ColumnName = "总 ";
dt.Columns[ "R "].ColumnName = "R ";