You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Manjuka Soysa <Ma...@colesmyer.com.au> on 2005/04/29 05:25:31 UTC

Problems + fix (hack) for with sheet including macros

Hi,
I got an error when loading a spreadsheet containing macros.
I tracked it down to the StringPtg constructor, where field_1_length was
getting a negative value.
The fix is shown below. This leads to a warning when loading the sheet, but
seems ok after that.
If anyone wants a spreadhseet that causes the problem, let me know.

    public StringPtg(byte [] data, int offset)
    {
        offset++;
        field_1_length = data[offset];
        field_2_options = data[offset+1];
        if (fHighByte.isSet(field_2_options)) {
            field_3_string=
StringUtil.getFromUnicode(data,offset+2,field_1_length);
//MANJUKA added condition to prevent exception
        } else if (field_1_length < 0) { 
            field_3_string = "";
            field_1_length = 0;        
        }else {
 
field_3_string=StringUtil.getFromCompressedUnicode(data,offset+2,field_1_len
gth);
        }
				 
        //setValue(new String(data, offset+3, data[offset+1] +
256*data[offset+2]));
    }

cheers,
Manjuka


This email and any attachments may contain privileged and confidential information and are intended for the named addressee only. If you have received this e-mail in error, please notify the sender and delete this e-mail immediately. Any confidentiality, privilege or copyright is not waived or lost because this e-mail has been sent to you in error. It is your responsibility to check this e-mail and any attachments for viruses.  No warranty is made that this material is free from computer virus or any other defect or error.  Any loss/damage incurred by using this material is not the sender's responsibility.  The sender's entire liability will be limited to resupplying the material.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/