回复 3楼 csharpluntan
不是数据库崩溃吧,因为我设置断点的时候能够看到从数据库中将数据都取出来了啊。就是将数据放在DataTable中的时候要每条数据添加到Excel中的时候就崩溃了。用的是一个for循环所以运行的速度慢,但是我觉得也不至于啊。60000*50的数据循环应该也能取出来啊。
string filenameTemp = "~/File/Temp/校友基本信息模板.xls";
workBook = app.Workbooks.Open(Server.MapPath(filenameTemp), Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
workSheet = (Microsoft.Office.Interop.Excel.Worksheet)workBook.Sheets.get_Item(1);
string Serverpath = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
Serverpath = Serverpath + "/MuseumCollectionsImage/";
int rowNumber = dt.Rows.Count;
int columnNumber = dt.Columns.Count;
for (int i = 0; i < rowNumber; i++)
{
for (int j = 0; j < columnNumber; j++)
{
range = workSheet.Cells[2 + i, j + 1];
workSheet.Cells[2 + i, j + 1] = dt.Rows[i][j].ToString();
}
}