服务器上 .net 2008 / excel 2003
- C# code
respObj.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); respObj.AppendHeader("Content-Disposition", "attachment;filename=" + strFileName); string strColHeaders = "", strLstItem = ""; int i = 0; DataSet dstObj = GetDataSet(strSQL, strTableName); DataTable dtblObj = dstObj.Tables[0]; DataRow[] drowObj = dtblObj.Select(""); // strTypeID=="1" if (strTypeID == "1") { for (i = 0; i <= dtblObj.Columns.Count - 2; i++) { strColHeaders += dtblObj.Columns[i].Caption.ToString() + "\t"; } strColHeaders += dtblObj.Columns[i].Caption.ToString() + "\n"; respObj.Write(strColHeaders); foreach (DataRow drowObjTmp in drowObj) { for (i = 0; i <= dtblObj.Columns.Count - 2; i++) { strLstItem += drowObjTmp[i].ToString() + "\t"; } strLstItem += drowObjTmp[i].ToString() + "\n"; respObj.Write(strLstItem); strLstItem = ""; } }
问题 win7 导出的Excel 打不开 有什么办法?