Getting out of memory error writing cell contents

D

David Thielen

For the code:

private const int BLK_SIZE = 16000;

while (off < data.Length)
{
int len = Math.Min(BLK_SIZE, data.Length - off);
string cellData = data.Substring(off, len);

string loc = "A" + row;
Range rng = sheet.get_Range(loc, loc);
rng.Value2 = cellData;

off += len;
row++;
}

I am getting:
System.OutOfMemoryException occurred
Message="Not enough storage is available to complete this operation.
(Exception from HRESULT: 0x8007000E (E_OUTOFMEMORY))"
Source=""
StackTrace:
at System.RuntimeType.ForwardCallToInvokeMember(String
memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes,
MessageData& msgData)
at Microsoft.Office.Interop.Excel.Range.set_Value2(Object )
at
AutoTag2010.net.windward.autotag.excel.ExcelDocumentData.SaveProfileToDoc(ExcelFramework
app) in
C:\src\version9\AutoTag\AutoTag2010\net\windward\autotag\excel\ExcelDocumentData.cs:line
161
InnerException:

This occurs after writing the first 2 blocks and trying to write the
3rd block. This is being written to a hidden worksheet where this is
the only content in the sheet.

??? - thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
C

Colbert Zhou [MSFT]

Hello Dave,

I checked the Excel 2003 and 2007 specification and limitation document,
http://office.microsoft.com/en-us/excel/HP051992911033.aspx
http://office.microsoft.com/en-us/excel/HP100738491033.aspx

Your codes look fine. It does not seem to hit any of the official
documented limitation. Actually, I have written some codes in my Excel
workbook in which I call some loops to set A1-A10 with 16000 length
strings. It works fine.

So which version of Excel you encounter this error? To give more help on
this, is it possible to share with me a reproduciable project and the data
you are using? After reproducing locally, I think I can do more
investigations and provide further support on this.

Have a nice day :)


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
D

David Thielen

This was 100% reproducable on Excel 2007. So I went back in to verify
today - and now it works. So something was screwy in Excel, but
whatever it was is gone.

I'll post again if I get it to happen again. These here yesterday,
gone today bugs drive me nuts.

thanks - dave



Hello Dave,

I checked the Excel 2003 and 2007 specification and limitation document,
http://office.microsoft.com/en-us/excel/HP051992911033.aspx
http://office.microsoft.com/en-us/excel/HP100738491033.aspx

Your codes look fine. It does not seem to hit any of the official
documented limitation. Actually, I have written some codes in my Excel
workbook in which I call some loops to set A1-A10 with 16000 length
strings. It works fine.

So which version of Excel you encounter this error? To give more help on
this, is it possible to share with me a reproduciable project and the data
you are using? After reproducing locally, I think I can do more
investigations and provide further support on this.

Have a nice day :)


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top