After looking at your code further, it looks like it should be working. My 
guess is that the cloneStyleFrom method is not working the way you would 
expect. I do not use this method, so I am not sure if there are issues with it. 
But, the easy way to find out, is to simply set your other borders to thin on 
the setBottomThickBorder method, and see if that works, and if it does, then 
you know it's an issue with how the clone method works.

I actually wrote a POI converter that takes CSS styles and converts them to POI 
Cell styles and creates a unique set of POI Cell styles for each variation. And 
then, this hashset is looked into (keyed on the Css style string) and its 
resulting Cell Style is used to set the styles of the cells, so that the 256 
cell style limit is maintained.

-----Original Message-----
Sent: Monday, August 13, 2012 7:59 AM
To: POI Users List
Subject: Re: Problem in Cell Borders

Yes this is possible.

However, you are thinking that the cell style you have created is independent 
for each cell, but that is not the case. In order to change any portion of a 
style to be different from another cell, you need to create another cell style 
object, set its properties, then assign it to the cell you want to be 
different. However, there is a slight caveat to this, you can only have a 
limited number of cell style objects, I believe it is 256 of them, so can not 
simply created a new cell style object for every cell.

-Geoff

Sent from my ASUS Eee Pad

harshask <[email protected]> wrote:

>Hi all,
>
>Is it possible to have two kinds of borders to a single cell using POI? 
>I wrote all sides border to a cell, and now require a thick border in 
>the bottom for those cells. When the thin border is written, the thick 
>border disappears or if i write the thick border first, the thin border 
>disappears.
>
>I have written the following methods to draw borders.
>
>*For All Sides Thin Border-*
>
> public void setAllSidesBorder(HSSFWorkbook hwb, HSSFSheet sheet,
>                                  HSSFCellStyle cellStyle, int rowNum,
>                                  int cellStart, int CellEnd) {
>        HSSFCellStyle cellStyleBotBord = hwb.createCellStyle();
>        if (cellStyle != null) {
>            cellStyleBotBord.cloneStyleFrom(cellStyle);
>        }
>        cellStyleBotBord.setBorderLeft(HSSFCellStyle.BORDER_THIN);
>        cellStyleBotBord.setBorderBottom(HSSFCellStyle.BORDER_THIN);
>        cellStyleBotBord.setBorderRight(HSSFCellStyle.BORDER_THIN);
>        cellStyleBotBord.setBorderTop(HSSFCellStyle.BORDER_THIN);
>        row = getRowObject(sheet, rowNum);
>        for (int j = cellStart; j <= CellEnd; j++) {
>            cell = getCellObject(row, j);
>            cell.setCellStyle(cellStyleBotBord);
>        }
>    }
>
>
>*For bottom Thick border - *
>
>public void setBottomThickBorder(HSSFWorkbook hwb, HSSFSheet sheet,
>                                     HSSFCellStyle cellStyle, int rowno,
>                                     int cellStart, int CellEnd) {
>        HSSFCellStyle cellStyleBotBord = hwb.createCellStyle();
>        if (cellStyle != null) {
>            cellStyleBotBord.cloneStyleFrom(cellStyle);
>        }
>        cellStyleBotBord.setBorderBottom(HSSFCellStyle.BORDER_THICK);
>        row = getRowObject(sheet, rowno);
>        cell = getCellObject(row, cellStart);
>        cell.setCellStyle(cellStyleBotBord);
>        for (int i = cellStart + 1; i < CellEnd; i++) {
>            cell = getCellObject(row, i);
>            cell.setCellStyle(cellStyleBotBord);
>        }
>        cell = getCellObject(row, CellEnd);
>        cell.setCellStyle(cellStyleBotBord);
>    }
>
>Plz help me out...
>
>Thanks,
>Harsha
>
>
>
>--
>View this message in context: 
>http://apache-poi.1045710.n5.nabble.com/Problem-in-Cell-Borders-tp57106
>83.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]
>

---------------------------------------------------------------------
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