0
我在服務器中有2個excel文件,每個文件大小爲1GB。 我必須比較這些文件,並應將結果發送到單獨的表格中。System.OutofMemory異常excel 1 GB數據
我能夠讀取一個excel文件到數據表中,當我正在讀取另一個excel的數據時,我會發現內存異常。
file = new FileInfo(@"Remote Location" + strFileName);
bool hasHeader = true;
file.CopyTo(strPath, true);
file = null;
using (var pck = new OfficeOpenXml.ExcelPackage())
{
using (FileStream stream = File.OpenRead(strPath))
{
pck.Load(stream); //Getting issue out of memory for second excel file
stream.Close();
stream.Dispose();
}
}
偏離主題,但是如果您要使用using()塊,則不應該調用Dispose()。只是使用後者 – MickyD
其實我在使用前加入它..我刪除了displose並關閉..但仍然得到相同的異常。數據表是需要比較..所以如果我丟棄它,我可能會丟失數據。 – Lavin
您需要比較電子表格結構或其數據嗎? – qxg