ExcelSheet中没有足够的存储空间来完成此操作

我正在使用4张表格的.xls扩展名Excelsheet。 我正在写所有这些表单的XML内容。写入每个工作表后,我正在使用这种方法保存和收集垃圾

private static void SaveAndCollecttheGarbage(Microsoft.Office.Interop.Excel.Application excelApp, string path, Microsoft.Office.Interop.Excel.Sheets sheet) { try { excelApp.Columns.AutoFit(); mWorkBook.SaveAs(path, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); mWorkBook.Close(true, Missing.Value, Missing.Value); sheet = null; mWorkBook = null; excelApplication.Quit(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); } catch (Exception) { } } 

这对我所有的前3张工作正常,但是当来到我的第四张时,当单元格值为——–原始——和数据继续时抛出一个错误。 …

没有足够的存储空间来完成此操作。 (从HRESULTexception:0x8007000E(E_OUTOFMEMORY))

我的第四张纸有比其他纸张更多的数据(1100+ )。 这就是我写数据到第四张的方式

 mWorkBook = excelApplication.Workbooks.Open(excelPath, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false); mSheets = mWorkBook.Worksheets; mWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)mSheets.Add(); mWorkSheet.Name = "Case History"; int l = 1, m = 1, n = 0; mWorkSheet.Cells[1, 1] = "Id"; mWorkSheet.Cells[1, 2] = "Subject"; mWorkSheet.Cells[1, 3] = "CustomerHistory"; foreach (CaseHistory customerHistory in allCustomerHistory) { n = 0; mWorkSheet.Cells[l + m, ++n] = customerHistory.id; mWorkSheet.Cells[l + m, ++n] = customerHistory.caseSubject; mWorkSheet.Cells[l + m, ++n] = customerHistory.caseBody; m++; } 

我找不到我做错了什么。 难道不可能把大量的数据写入Excel表格。 如果可以帮助我如何做到这一点