I was saying that you should try that ALIGN_CENTER_SELECTION.
    Have you seen the examples:
http://jakarta.apache.org/poi/hssf/quick-guide.html#CellTypes

        HSSFCell cell = row.createCell(column);
        cell.setCellValue("Hello world");
        HSSFCellStyle cellStyle = wb.createCellStyle();
        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER_SELECTION);
        cell.setCellStyle(cellStyle);


----- Original Message -----
From: "Urban Spielmann" <[EMAIL PROTECTED]>
To: "POI Users List" <[EMAIL PROTECTED]>
Sent: Friday, September 12, 2003 1:18 AM
Subject: AW: How to use ALIGN_CENTER_SELECTION


Hi Steve

You described exactly how I do it in Excel, but I would like to do it with
HSSF.

Regards,
Urban

> -----Urspr�ngliche Nachricht-----
> Von: Steve [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 11. September 2003 18:36
> An: POI Users List
> Betreff: Re: How to use ALIGN_CENTER_SELECTION
>
>
> if you open excel, and do Format---Cells, you will see the
> option Center Across Selection as one of the choices for
> horizontal alignment.  If you test this on an excel
> worksheet, it seems this gives  the functionality that you
> want. That is, the selection aspect is not a problem.  As to
> whether this is working in HSSF, I do not know. I've never
> tried it. But, it seems that the option
> ALIGN_CENTER_SELECTION is meant for this.
>
> You could also put a string in one cell, and then align
> center, which centers the string based on the one cell with
> contents spilling into left and right cells. However, this
> will not take into account the widths of the cells to the
> left and right of the cell where you put the string.
>
> I hope this is of some help.
> --steve
> ----- Original Message -----
> From: "Urban Spielmann" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, September 11, 2003 3:19 AM
> Subject: How to use ALIGN_CENTER_SELECTION
>
>
> Hi all,
>
> How can I center a parent-title over some child-titles?
>
> Example:
>         HSSFRow row02 = sheet.createRow((short) 1);
>         row02.createCell((short) 0).setCellValue("Title 1");
> // Cell A2
>         row02.createCell((short) 1).setCellValue("Title 2");
> // Cell B2
>         row02.createCell((short) 2).setCellValue("Title 3");
> // Cell C2
>
>         HSSFRow row01 = sheet.createRow((short) 0);
>         HSSFCell cell = row01.createCell((short) 0);  // Cell A1
>         cell.setCellValue("Parent Title");
>         // TODO: Alignment over Cell A1 to Cell C1
>
> The "Parent Title" should span from cell 0 to cell 2.
> Can I use the HSSFCellStyle.ALIGN_CENTER_SELECTION for that?
> How do I make a selection?
>
> I know one possibility would be to do it with merged cells.
> But merged cells have the disadvantage that it is not
> possible to have partial-selections on the merged region
> (e.g. selection over C1, C2, C3 in my example).
>
> Thanks a lot for any help.
>
> Best regards,
> Urban
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to