i'm working on excelsheet of .xls extensions 4 sheets in it. i'm writing xml content these sheets.after writing each sheet i'm saving , collecting garbage using method
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) { } }
this working fine first 3 sheets when coming 4th sheet throwing error when cell value --------original------and data goes on.....
not enough storage available complete operation. (exception hresult: 0x8007000e (e_outofmemory))
my 4th sheet has more data (1100+ rows) other sheets. how i'm writing data 4th sheet
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++; }
i cannot find i'm doing wrong. isn't possible write huge data excelsheet. if can me how it
Comments
Post a Comment