1 16 17 package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements; 18 19 import org.apache.poi.hssf.usermodel.HSSFCell; 20 import org.apache.poi.hssf.usermodel.HSSFRow; 21 22 import java.io.IOException ; 23 24 30 31 33 class Row { 34 private HSSFRow _row; 35 private Sheet _sheet; 36 37 41 Row(final HSSFRow row, final Sheet sheet) { 42 _row = row; 43 _sheet = sheet; 44 } 45 46 51 void setHeight(final double points) throws IOException { 52 if (!isValid(points)) { 53 throw new IOException ("points " + points + " is out of range"); 54 } 55 _row.setHeight((short) (points * 20)); 56 } 57 58 62 short getHeight() { 63 return _row.getHeight(); 64 } 65 66 73 Cell createCell(final int column, final int cellType) throws IOException { 74 if (column < 0 || column > Short.MAX_VALUE) { 75 throw new IOException ("Illegal column value: " + column); 76 } 77 HSSFCell hssfCell = _row.createCell((short)column); 78 hssfCell.setCellType(CellType.convertCellType(cellType)); 79 80 Cell cell = new Cell(hssfCell, cellType); 81 cell.setStyle(_sheet.getCellStyleForRegion(_row.getRowNum(), 82 (short)column)); 83 return cell; 84 } 85 86 private boolean isValid(double points) { 87 return ((points >= 0) && (points <= (((double)Short.MAX_VALUE) / 20))); 88 } 89 } | Popular Tags |