You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Julien Bittard <ju...@unilog.logicacmg.com> on 2006/09/21 12:12:09 UTC

Problem with outline

Hello,

In my workbook I create outline with several level and I collapsed all the
level. But when I open the final document, some level are expanded. I don't
know why !
I put an example in this mail. If you open the first level, then you see my
problem : the first sub-level are open, but the second no, etc..
In my source code, I create outline whith groupRow(startRow, endRow) and so
I collapsed this outline with setRowGroupCollapsed(startRow, true).

Does anyone have any ideas ?

thanks


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.

Re: Problem with cell formatting.

Posted by de...@yahoo.com.
> Is there a way to only affect the format of the
cell?

Use HSSFWorkbook.createCellStyle to create a new cell
style and set the data format and use that for the
target cell. 

Cell Styles are shared (technically, the underlying
extendedformatrecord is shared). So changing the
dataformat of a cell style will affect all cells that
share the same cell style (in your case, all the
cells)

hth,
~ amol




--- Amir Khan <am...@deliveredsolutions.co.uk> wrote:

> Hi,
> 
> I've noticed that when I run the following method
> that I've written all 
> the formats for all the unsed cells are changed to
> the format I pass in.
> Is there a way to only affect the format of the
> cell?, I might be doing 
> this wrong?. I thought i'm only affecting the one
> cell.
> 
>     /**
>      * set a cell in the work book (in right sheet)
> as date.
>      * <p/>
>      *
>      * @param sheet the sheet we want to update
>      * @param date  is the date you want to set
>      * @param x     is the X co-ord
>      * @param y     is the y co-ord
>      * @param mask  is the formatting mask used
>      */
>     public void setValueOfCellAsDateInSheet(int
> sheet,
>                                             Date
> date,
>                                             int x,
>                                             int y,
>                                             String
> mask) {
>         HSSFCell theCell = ensureCellExists(sheet,
> x, y);
>         HSSFCellStyle dateCellStyle =
> theCell.getCellStyle();
>         HSSFDataFormat format =
> workbook.createDataFormat();
>        
> dateCellStyle.setDataFormat(format.getFormat(mask));
>         theCell.setCellValue(date);
>     }
> 
> Here is the method I used in the above method (in
> case it matters) ...
> 
> /**
>      * Given a sheet, x and y this method will
> create all the parents 
> bits and
>      * the cell to ensure it exists in the workbook
>      */
>     protected HSSFCell ensureCellExists(int sheet,
>                                         int x,
>                                         int y) {
>         HSSFSheet theSheet =
> workbook.getSheetAt(sheet);
>         HSSFRow theRow = theSheet.getRow(y);
>         if (null == theRow) {
>             theRow = theSheet.createRow(y);
>         }
>         HSSFCell theCell = theRow.getCell((short)
> x);
>         if (null == theCell) {
>             theCell = theRow.createCell((short) x);
>         }
>         return theCell;
>     }
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> poi-user-unsubscribe@jakarta.apache.org
> Mailing List:    
> http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: 
> http://jakarta.apache.org/poi/
> 
> 


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


Problem with cell formatting.

Posted by Amir Khan <am...@deliveredsolutions.co.uk>.
Hi,

I've noticed that when I run the following method that I've written all 
the formats for all the unsed cells are changed to the format I pass in.
Is there a way to only affect the format of the cell?, I might be doing 
this wrong?. I thought i'm only affecting the one cell.

    /**
     * set a cell in the work book (in right sheet) as date.
     * <p/>
     *
     * @param sheet the sheet we want to update
     * @param date  is the date you want to set
     * @param x     is the X co-ord
     * @param y     is the y co-ord
     * @param mask  is the formatting mask used
     */
    public void setValueOfCellAsDateInSheet(int sheet,
                                            Date date,
                                            int x,
                                            int y,
                                            String mask) {
        HSSFCell theCell = ensureCellExists(sheet, x, y);
        HSSFCellStyle dateCellStyle = theCell.getCellStyle();
        HSSFDataFormat format = workbook.createDataFormat();
        dateCellStyle.setDataFormat(format.getFormat(mask));
        theCell.setCellValue(date);
    }

Here is the method I used in the above method (in case it matters) ...

/**
     * Given a sheet, x and y this method will create all the parents 
bits and
     * the cell to ensure it exists in the workbook
     */
    protected HSSFCell ensureCellExists(int sheet,
                                        int x,
                                        int y) {
        HSSFSheet theSheet = workbook.getSheetAt(sheet);
        HSSFRow theRow = theSheet.getRow(y);
        if (null == theRow) {
            theRow = theSheet.createRow(y);
        }
        HSSFCell theCell = theRow.getCell((short) x);
        if (null == theCell) {
            theCell = theRow.createCell((short) x);
        }
        return theCell;
    }


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


RE: Problem with outline

Posted by Julien Bittard <ju...@unilog.logicacmg.com>.
Hello,

I noticed that in the method collapseRow of the class RowRecordsAggregate ,
a setColapsed(true) was made on the lastRow of the group, but not on the
startRow. If I add a setColapsed(true) on the startRow my problem is solved.
What do you think about that ?
thank you.

  -----Message d'origine-----
  De : Julien Bittard [mailto:julien.bittard@unilog.logicacmg.com]
  Envoyé : jeu. 21 septembre 2006 12:12
  À : POI Users List
  Objet : Problem with outline


  Hello,

  In my workbook I create outline with several level and I collapsed all the
level. But when I open the final document, some level are expanded. I don't
know why !
  I put an example in this mail. If you open the first level, then you see
my problem : the first sub-level are open, but the second no, etc..
  In my source code, I create outline whith groupRow(startRow, endRow) and
so I collapsed this outline with setRowGroupCollapsed(startRow, true).

  Does anyone have any ideas ?

  thanks



  This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.