Hello,
I'm a new POI-User and searching for a solution to shift checkboxes with
POI. I have to read an Excel-File-Template which contains a table and a few
checkboxes.   
Because of dynamical data I have to create some new rows in the table. It
works fine, but the row-dependent CheckBox (ControlBox) is still at the old
place and has to be moved down.

By searching for a solution I have seen how to search for the
EscherClientAnchorRecord of a CheckBox and how to increase the
Anchor-Coordinates (Code below). 

And it works ,  I can shift the Checkboxes! 

But because there exists chechboxes in the Excel-template the call of 
"HSSFSheet.getDrawingEscherAggregate()" causes a corruption of the file. 

A testcall of getDrawingEscherAggregate() without a checkbox in the template
works fine. So there isn't any CheckBox Support.

 Unfortunately when I open the "corrupted" generated POI-Excel File, Excel
shows a Error-Message Popup-Window, that there are may be lost data. 

Now my question:

Is there another way or hack to shift a Checkbox, without a corruption in
the Excel-File? (It's a normal CheckBox - not an ActiveX-One)

What can I do? Any Idea's? 

Thanks for answeres - Michael. 


Row sourceRow = sheet.getRow(13);
sheet.shiftRows(13+i, sheet.getLastRowNum(), 1, true, false);
Row newRow = sheet.createRow(13+i);


EscherContainerRecord escherContainer = null;                                   
                                                                
EscherAggregate escherAggregate = (EscherAggregate)((HSSFSheet)
sheet).getDrawingEscherAggregate();
if(escherAggregate != null) {
        escherContainer = escherAggregate.getEscherContainer();
      if (shiftrow) {
           this.iterateContainer(escherContainer, level);
      }  
} 

private void iterateContainer(EscherContainerRecord escherContainer, int
level) {
        List childContainers = escherContainer.getChildContainers();
        List childRecords = escherContainer.getChildRecords();
        Iterator listIterator = childContainers.iterator();
        EscherClientAnchorRecord anchrRecord = null;
        Object next = null;
        
        while(listIterator.hasNext()) {
            next = listIterator.next();
            if(next instanceof org.apache.poi.ddf.EscherContainerRecord) {
               
              
this.iterateContainer((org.apache.poi.ddf.EscherContainerRecord)next,++level);
            }
        }
        listIterator = childRecords.iterator();
        while(listIterator.hasNext()) {
            next = listIterator.next();
            if(next instanceof org.apache.poi.ddf.EscherContainerRecord) {
              
this.iterateContainer((org.apache.poi.ddf.EscherContainerRecord)next);
            }
            else {
                else if(next instanceof
org.apache.poi.ddf.EscherClientAnchorRecord) {
                    anchrRecord =
(org.apache.poi.ddf.EscherClientAnchorRecord)next;              
                    if (anchrRecord != null) {
                      // move the Checkbox-Position
                    }
                }
        }
    }
-- 
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/POI-CheckBox-Support-How-to-shift-a-CheckBox-without-Excel-corruption-tp3213442p3213442.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