You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by sc...@gmx.de on 2015/07/23 13:14:46 UTC

How can I GET the diagonal border for a Cell?

Hi list,

I know how to get the bottom, top, left and right:
        CellStyle style = cell.getCellStyle();
        CellReference cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex());
        System.out.println(cellRef + " Bottom: " + style.getBorderBottom());
        System.out.println(cellRef + " Top: " + style.getBorderTop());
        System.out.println(cellRef + " Left: " + style.getBorderLeft());
        System.out.println(cellRef + " Right: " + style.getBorderRight());
        
But how do I get the diagonal down and diagonal up? 

Thanks for your help!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Re: How can I GET the diagonal border for a Cell?

Posted by Dominik Stadler <do...@gmx.at>.
Hi,

The following makes this work for me for a cell:

        Cell cell = row.createCell(1);
        cell.setCellValue("somevalue");
        CellStyle cellStyle = wb.createCellStyle();

        XSSFCellStyle cs = (XSSFCellStyle) cellStyle;
        StylesTable table = null;
        for(POIXMLDocumentPart part : ((XSSFWorkbook)wb).getRelations()) {
            if(part instanceof StylesTable) {
                table = (StylesTable) part;
                break;
            }
        }
        assertNotNull("Had: " + ((XSSFWorkbook)wb).getRelations(),
                table);

        CTBorder ct = CTBorder.Factory.newInstance();

        ct.setDiagonalUp(true);

        CTBorderPr pr = ct.isSetDiagonal() ? ct.getDiagonal() :
ct.addNewDiagonal();
        Enum borderStyle = STBorderStyle.Enum.forString("thin");
        pr.setStyle(borderStyle);
        ct.setDiagonal(pr);

        int idx = table.putBorder(new XSSFCellBorder(ct, null));

        cs.getCoreXf().setBorderId(idx);
        cs.getCoreXf().setApplyBorder(true);

        cell.setCellStyle(cellStyle);


naturally it would be nice to integrate this into POI itself, maybe
you are able to build a patch and put it into a bugzilla entry?

Thanks... Dominik.

On Mon, Aug 10, 2015 at 10:43 PM, Dominik Stadler
<do...@gmx.at> wrote:
> Hi,
>
> sorry for not answering, I was on vacation last week.
>
> I quickly tried to put together a few lines of code which show this,
> but unfortunately the diagonal borders seem to be handled differently
> in the spec as the normal borders and thus require a bit more work,
> let me give it another try later this week to see if it can be done or
> actually needs changes in POI itself after all...
>
> Thanks... Dominik.
>
> On Tue, Jul 28, 2015 at 11:18 AM,  <sc...@gmx.de> wrote:
>> Hi Dominik,
>>
>> thanks for getting back to me on this issue. I created a simple file with some borders. Here is what I found out:
>> In the styles.xml file I found under: <borders count="7">
>> the following entry which looks like what I need:
>> <border diagonalDown="1">
>>             <left/>
>>             <right/>
>>             <top/>
>>             <bottom/>
>>             <diagonal style="thin">
>>                 <color auto="1"/>
>>             </diagonal>
>>         </border>
>>         <border diagonalUp="1">
>>             <left/>
>>             <right/>
>>             <top/>
>>             <bottom/>
>>             <diagonal style="thin">
>>                 <color auto="1"/>
>>             </diagonal>
>>         </border>
>>
>> So what I did was create a couple of cells with borders and two with diagonal up and down borders. How can I now read those properties with POI? Or how does such a lower level API call look like to get those attributes? Thanks a lot already for your help.
>>
>> Regards
>>
>> Gesendet: Montag, 27. Juli 2015 um 18:41 Uhr
>> Von: "Dominik Stadler" <do...@gmx.at>
>> An: "POI Users List" <us...@poi.apache.org>
>> Betreff: Re: How can I GET the diagonal border for a Cell?
>> Hi,
>>
>> It seems the POI interface does not provide this currently, can you
>> create two very simple files that are very similar, only one without
>> this and one with this formatting and then compare the XML-files
>> inside the .XLSX? .xlsx-files are just ZIPs, so you can unpack them
>> and compare the files in there.
>>
>> When you know which data needs to be set, it is usually possible to
>> use a lower level API to set these flags in POI until a full API
>> becomes available.
>>
>> Thanks... Dominik.
>>
>> On Thu, Jul 23, 2015 at 1:14 PM, <sc...@gmx.de> wrote:
>>> Hi list,
>>>
>>> I know how to get the bottom, top, left and right:
>>> CellStyle style = cell.getCellStyle();
>>> CellReference cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex());
>>> System.out.println(cellRef + " Bottom: " + style.getBorderBottom());
>>> System.out.println(cellRef + " Top: " + style.getBorderTop());
>>> System.out.println(cellRef + " Left: " + style.getBorderLeft());
>>> System.out.println(cellRef + " Right: " + style.getBorderRight());
>>>
>>> But how do I get the diagonal down and diagonal up?
>>>
>>> Thanks for your help!
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>>> For additional commands, e-mail: user-help@poi.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Re: How can I GET the diagonal border for a Cell?

Posted by Dominik Stadler <do...@gmx.at>.
Hi,

sorry for not answering, I was on vacation last week.

I quickly tried to put together a few lines of code which show this,
but unfortunately the diagonal borders seem to be handled differently
in the spec as the normal borders and thus require a bit more work,
let me give it another try later this week to see if it can be done or
actually needs changes in POI itself after all...

Thanks... Dominik.

On Tue, Jul 28, 2015 at 11:18 AM,  <sc...@gmx.de> wrote:
> Hi Dominik,
>
> thanks for getting back to me on this issue. I created a simple file with some borders. Here is what I found out:
> In the styles.xml file I found under: <borders count="7">
> the following entry which looks like what I need:
> <border diagonalDown="1">
>             <left/>
>             <right/>
>             <top/>
>             <bottom/>
>             <diagonal style="thin">
>                 <color auto="1"/>
>             </diagonal>
>         </border>
>         <border diagonalUp="1">
>             <left/>
>             <right/>
>             <top/>
>             <bottom/>
>             <diagonal style="thin">
>                 <color auto="1"/>
>             </diagonal>
>         </border>
>
> So what I did was create a couple of cells with borders and two with diagonal up and down borders. How can I now read those properties with POI? Or how does such a lower level API call look like to get those attributes? Thanks a lot already for your help.
>
> Regards
>
> Gesendet: Montag, 27. Juli 2015 um 18:41 Uhr
> Von: "Dominik Stadler" <do...@gmx.at>
> An: "POI Users List" <us...@poi.apache.org>
> Betreff: Re: How can I GET the diagonal border for a Cell?
> Hi,
>
> It seems the POI interface does not provide this currently, can you
> create two very simple files that are very similar, only one without
> this and one with this formatting and then compare the XML-files
> inside the .XLSX? .xlsx-files are just ZIPs, so you can unpack them
> and compare the files in there.
>
> When you know which data needs to be set, it is usually possible to
> use a lower level API to set these flags in POI until a full API
> becomes available.
>
> Thanks... Dominik.
>
> On Thu, Jul 23, 2015 at 1:14 PM, <sc...@gmx.de> wrote:
>> Hi list,
>>
>> I know how to get the bottom, top, left and right:
>> CellStyle style = cell.getCellStyle();
>> CellReference cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex());
>> System.out.println(cellRef + " Bottom: " + style.getBorderBottom());
>> System.out.println(cellRef + " Top: " + style.getBorderTop());
>> System.out.println(cellRef + " Left: " + style.getBorderLeft());
>> System.out.println(cellRef + " Right: " + style.getBorderRight());
>>
>> But how do I get the diagonal down and diagonal up?
>>
>> Thanks for your help!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Aw: Re: How can I GET the diagonal border for a Cell?

Posted by sc...@gmx.de.
Hi Dominik,
 
thanks for getting back to me on this issue. I created a simple file with some borders. Here is what I found out:
In the styles.xml file I found under: <borders count="7">
the following entry which looks like what I need:
<border diagonalDown="1">
            <left/>
            <right/>
            <top/>
            <bottom/>
            <diagonal style="thin">
                <color auto="1"/>
            </diagonal>
        </border>
        <border diagonalUp="1">
            <left/>
            <right/>
            <top/>
            <bottom/>
            <diagonal style="thin">
                <color auto="1"/>
            </diagonal>
        </border>
 
So what I did was create a couple of cells with borders and two with diagonal up and down borders. How can I now read those properties with POI? Or how does such a lower level API call look like to get those attributes? Thanks a lot already for your help.

Regards 

Gesendet: Montag, 27. Juli 2015 um 18:41 Uhr
Von: "Dominik Stadler" <do...@gmx.at>
An: "POI Users List" <us...@poi.apache.org>
Betreff: Re: How can I GET the diagonal border for a Cell?
Hi,

It seems the POI interface does not provide this currently, can you
create two very simple files that are very similar, only one without
this and one with this formatting and then compare the XML-files
inside the .XLSX? .xlsx-files are just ZIPs, so you can unpack them
and compare the files in there.

When you know which data needs to be set, it is usually possible to
use a lower level API to set these flags in POI until a full API
becomes available.

Thanks... Dominik.

On Thu, Jul 23, 2015 at 1:14 PM, <sc...@gmx.de> wrote:
> Hi list,
>
> I know how to get the bottom, top, left and right:
> CellStyle style = cell.getCellStyle();
> CellReference cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex());
> System.out.println(cellRef + " Bottom: " + style.getBorderBottom());
> System.out.println(cellRef + " Top: " + style.getBorderTop());
> System.out.println(cellRef + " Left: " + style.getBorderLeft());
> System.out.println(cellRef + " Right: " + style.getBorderRight());
>
> But how do I get the diagonal down and diagonal up?
>
> Thanks for your help!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How can I GET the diagonal border for a Cell?

Posted by Dominik Stadler <do...@gmx.at>.
Hi,

It seems the POI interface does not provide this currently, can you
create two very simple files that are very similar, only one without
this and one with this formatting and then compare the XML-files
inside the .XLSX? .xlsx-files are just ZIPs, so you can unpack them
and compare the files in there.

When you know which data needs to be set, it is usually possible to
use a lower level API to set these flags in POI until a full API
becomes available.

Thanks... Dominik.

On Thu, Jul 23, 2015 at 1:14 PM,  <sc...@gmx.de> wrote:
> Hi list,
>
> I know how to get the bottom, top, left and right:
>         CellStyle style = cell.getCellStyle();
>         CellReference cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex());
>         System.out.println(cellRef + " Bottom: " + style.getBorderBottom());
>         System.out.println(cellRef + " Top: " + style.getBorderTop());
>         System.out.println(cellRef + " Left: " + style.getBorderLeft());
>         System.out.println(cellRef + " Right: " + style.getBorderRight());
>
> But how do I get the diagonal down and diagonal up?
>
> Thanks for your help!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org