Hello David,

Can I ask, does the sheet already contain and graphics? The reason I ask is
that the javadocs for that method say the following;

"getDrawingPatriarch

public HSSFPatriarch getDrawingPatriarch()

    Returns the top-level drawing patriach, if there is one. This will hold
any graphics or charts for the sheet. WARNING - calling this will trigger a
parsing of the associated escher records. Any that aren't supported (such as
charts and complex drawing types) will almost certainly be lost or corrupted
when written out. Only use this with simple drawings, otherwise call
createDrawingPatriarch() and start from scratch!"

I know this will not help you solve the problem but it may help to determine
the cause.

Yours

Mark B


David Cao-2 wrote:
> 
> Hi there,
> 
> I used the following code to grab an instance of HSSFPatriarch (to create
> a 
> HSSFComment in the sheet).
> 
>         HSSFPatriarch patr = sheet.getDrawingPatriarch();
>         if (patr == null) {
>               patr = sheet.createDrawingPatriarch();
>         }
> 
> However, I get the following exception thrown from 
> "sheet.getDrawingPatriarch()". Does anybody have an idea of why this
> happening?
> 
> thanks a lot,
> -david
> 
> Exception in thread "main" java.lang.NullPointerException
>       at 
> org.apache.poi.hssf.record.AbstractEscherHolderRecord.convertRawBytesToEscherRec
> ords(AbstractEscherHolderRecord.java:73)
>       at 
> org.apache.poi.hssf.record.DrawingGroupRecord.processChildRecords(DrawingGroupRe
> cord.java:83)
>       at 
> org.apache.poi.hssf.model.Workbook.findDrawingGroup(Workbook.java:2227)
>       at 
> org.apache.poi.hssf.usermodel.HSSFSheet.getDrawingEscherAggregate(HSSFSheet.java
> :1531)
>       at 
> org.apache.poi.hssf.usermodel.HSSFSheet.getDrawingPatriarch(HSSFSheet.java:1565)
>       at 
> icn.bellaliant.parser.msexcel.test.CellComments.createComment(CellComments.java:
> 38)
>       at 
> icn.bellaliant.parser.msexcel.test.CellComments.main(CellComments.java:80)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/NullPointerException-in-getDrawingPatriarch%28%29-of-HSSFSheet-object-tp24205001p24215889.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to