poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Groskreutz <gros...@versifit.com>
Subject Re: Problem in Cell Borders
Date Mon, 13 Aug 2012 12:59:07 GMT
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 <hsk.1988@gmail.com> 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-tp5710683.html
>Sent from the POI - User mailing list archive at Nabble.com.
>
>---------------------------------------------------------------------
>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
Mime
View raw message