i'm working excel sheet of .xls format , writing data it. problem whenever data doesn't start alphabets prompting me different errors.
for example: when column data started =?us-ascii?q?google keywords?= threw me exception:
exception hresult: 0x800a03ec
and when data -------- original message --------subject: error was:
not enough storage available complete operation. (exception hresult: 0x8007000e (e_outofmemory))
this how i'm writing data:
foreach (allcasesreplies infolist in allcasesreplies) { n = 0; mworksheet.cells[l + m, ++n] = infolist.id; mworksheet.cells[l + m, ++n] = infolist.replies; m++; }
this how clean objects:
private static void saveandcollectthegarbage(microsoft.office.interop.excel.application excelapp, string path, microsoft.office.interop.excel.sheets sheet) { 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(); }
so have tried omitting these data , working great.
are there rules column has start specific characters , if so, these?
if type "?" in excel cell has general format, excel automaticall interprete formula. need change cell format before inserting text cell.
something like:
foreach (allcasesreplies infolist in allcasesreplies) { n = 0; microsoft.office.interop.excel.range range1 = mworksheet.cells[l + m, ++n] range; range1.numberformat = "@"; range1.value2 = infolist.id; microsoft.office.interop.excel.range range2 = mworksheet.cells[l + m, ++n] range; range2.numberformat = "@"; range2.value2 = infolist.replies; m++; }
Comments
Post a Comment