Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

writing long text in excel workbook using interop throws error?

I am writing long text (1K to 2K characters long, plain xml data) into a cell in excel workbook. The below statement throws COM error Exception from HRESULT: 0x800A03EC

range.set_Value(Type.Missing, data);

If I copy paste the same xml manually into excel it just works fine ,but the same does not work progamatically. If I strip the text to something like 100/300 chars it works fine.

like image 743
dotnetcoder Avatar asked Jun 24 '09 08:06

dotnetcoder


2 Answers

There is a limit (somehwere between 800 and 900 chars if i remember correctly) that is nearly impossible to get around like this.

Try using an ole connection and inserting the data with an SQL command. That might work better for you. you can then use interop to do any formatting if necessary.

like image 200
cjk Avatar answered Oct 05 '22 08:10

cjk


the following KB article explains that the max limit is 911 characters. I checked the same on my code it does work for string upto 911 chars.

http://support.microsoft.com/kb/818808

The work around mentioned in this article recommends to make sure no cell holds more than 911 characters. thats lame!

like image 38
dotnetcoder Avatar answered Oct 05 '22 08:10

dotnetcoder