Sistemim, Java'dan Apache POI kullanarak çok sayıda farklı Excel raporu üretir.Apache'de bir CellStyle kitaplığı oluşturma POI
Bu raporların çoğu aynı stilleri paylaşır.
Tüm raporlarda kullanılmak üzere bir CellStyle kitaplığı oluşturdum. Daha iyi bir yol olup olmadığını merak ettim.
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Workbook;
public class CellStyles {
CellStyle headingCellStyle = null;
Workbook wb;
public CellStyles(Workbook wb) {
this.wb = wb;
}
public CellStyle getHeadingCellStyle() {
if (headingCellStyle == null) {
headingCellStyle = wb.createCellStyle();
headingCellStyle.setFillForegroundColor(HSSFColor.YELLOW.index);
headingCellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
}
return headingCellStyle;
}
}
ve sonra o
Workbook wb = new XSSFWorkbook(inputStream); // XSSF for .xlsm
CellStyles cs = new CellStyles(wb);
CellUtil.getCell(myRow, 2).setCellStyle(cs.getHeadingCellStyle());
Yeterli görünüyor –