use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class RegionUtil method setTopBorderColor.
/**
* Sets the top border color for a region of cells by manipulating the cell style of the individual
* cells on the top
*
* @param color The color of the border
* @param region The region that should have the border
* @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
*/
public static void setTopBorderColor(int color, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn();
int colEnd = region.getLastColumn();
int rowIndex = region.getFirstRow();
CellPropertySetter cps = new CellPropertySetter(CellUtil.TOP_BORDER_COLOR, color);
Row row = CellUtil.getRow(rowIndex, sheet);
for (int i = colStart; i <= colEnd; i++) {
cps.setProperty(row, i);
}
}
use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class RegionUtil method setBottomBorderColor.
/**
* Sets the bottom border color for a region of cells by manipulating the cell style of the individual
* cells on the bottom
*
* @param color The color of the border
* @param region The region that should have the border
* @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
*/
public static void setBottomBorderColor(int color, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn();
int colEnd = region.getLastColumn();
int rowIndex = region.getLastRow();
CellPropertySetter cps = new CellPropertySetter(CellUtil.BOTTOM_BORDER_COLOR, color);
Row row = CellUtil.getRow(rowIndex, sheet);
for (int i = colStart; i <= colEnd; i++) {
cps.setProperty(row, i);
}
}
use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class RegionUtil method setBorderBottom.
/**
* Sets the bottom border style for a region of cells by manipulating the cell style of the individual
* cells on the bottom
*
* @param border The new border
* @param region The region that should have the border
* @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
* @deprecated POI 3.16 beta 1. Use {@link #setBorderBottom(BorderStyle, CellRangeAddress, Sheet)}.
*/
@Removal(version = "3.18")
public static void setBorderBottom(int border, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn();
int colEnd = region.getLastColumn();
int rowIndex = region.getLastRow();
CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_BOTTOM, border);
Row row = CellUtil.getRow(rowIndex, sheet);
for (int i = colStart; i <= colEnd; i++) {
cps.setProperty(row, i);
}
}
use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class RegionUtil method setBorderTop.
/**
* Sets the top border style for a region of cells by manipulating the cell style of the individual
* cells on the top
*
* @param border The new border
* @param region The region that should have the border
* @param sheet The sheet that the region is on.
* @since POI 3.16 beta 1
*/
public static void setBorderTop(BorderStyle border, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn();
int colEnd = region.getLastColumn();
int rowIndex = region.getFirstRow();
CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_TOP, border);
Row row = CellUtil.getRow(rowIndex, sheet);
for (int i = colStart; i <= colEnd; i++) {
cps.setProperty(row, i);
}
}
use of org.apache.poi.ss.usermodel.Row in project poi by apache.
the class SheetBuilder method build.
/**
* Builds sheet from parent workbook and 2D array with cell
* values. Creates rows anyway (even if row contains only null
* cells), creates cells if either corresponding array value is not
* null or createEmptyCells property is true.
* The conversion is performed in the following way:
* <p/>
* <ul>
* <li>Numbers become numeric cells.</li>
* <li><code>java.util.Date</code> or <code>java.util.Calendar</code>
* instances become date cells.</li>
* <li>String with leading '=' char become formulas (leading '='
* will be truncated).</li>
* <li>Other objects become strings via <code>Object.toString()</code>
* method call.</li>
* </ul>
*
* @return newly created sheet
*/
public Sheet build() {
Sheet sheet = (sheetName == null) ? workbook.createSheet() : workbook.createSheet(sheetName);
Row currentRow = null;
Cell currentCell = null;
for (int rowIndex = 0; rowIndex < cells.length; ++rowIndex) {
Object[] rowArray = cells[rowIndex];
currentRow = sheet.createRow(rowIndex);
for (int cellIndex = 0; cellIndex < rowArray.length; ++cellIndex) {
Object cellValue = rowArray[cellIndex];
if (cellValue != null || shouldCreateEmptyCells) {
currentCell = currentRow.createCell(cellIndex);
setCellValue(currentCell, cellValue);
}
}
}
return sheet;
}
Aggregations