Hello, I am hoping someone can help me out. I searched the web for an answer but cannot find one.
My program does some processing and creates an excel log file. Sometimes it has to put data (a string) in a cell that is 1000 characters long. But when the code tries to put the long string into the cell, I get the following error:

Win32::OLE(0.1403) error 0x80020009: "Exception occurred" in PROPERTYPUT "Value" at ProcessData.pl line 709

And when I check the excel doc after the processing is done the really long strings that caused the exceptions where not inserted into cells that they were suppose to get inserted into. I'm not doing anything special but I am thinking that I might have to. The problem is only when Excel 2003 is installed. If I run the same code on a machine with Excel 2007 installed everything works fine. Here is the code that puts the string into the excel file.

$worksheet = $workbook->Worksheets(3); $worksheet->{Name} = "Invalid Messages"; $worksheet->Range("A:A")->{HorizontalAlignment} = xlHAlignLeft; $worksheet->Range("A:A")->{ColumnWidth} = 10; $worksheet->Range("B:B")->{HorizontalAlignment} = xlHAlignLeft; $worksheet->Range("B:B")->{ColumnWidth} = 200; # Process all of the 'bad' messages. my $sTextData; foreach $sMsg (@aBadMessages) { @Params = split('\|', $sMsg); $sTextData = @Params[1]; $range = $worksheet->Range(sprintf("%s%d:%s%d", 'A', $nRow, 'C +', $nRow)); $range->{Value} = [@Params[0], $sTextData, @Params[$#Params]]; } $workbook->SaveAs($sLogFileName); $ExcelLog->Quit(); # leave excel


I know a 1000 character length string can go into a cell through the UI but its not working through my perl code. Is there something I need to do before putting the 1000 character string into the cell?

Any help would be greatly appreciated. Thanks.

In reply to Problem adding long string to excel cell by Anchor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.