List of usage examples for org.apache.poi.ss.usermodel Row setRowStyle
void setRowStyle(CellStyle style);
From source file:se.mithlond.services.content.impl.ejb.report.ExcelReportServiceBeanTest.java
License:Apache License
@Test public void validateCreatingSheetAndContent() throws Exception { // Assemble/* w w w . j a va 2 s. co m*/ final File targetFile = getTargetFile("ExcelFile", "xls"); final Workbook workbook = unitUnderTest.createDocument(memHaxx, "SomeDocument"); final List<String> columnTitles = Arrays.asList("Column_1", "Column_2"); // Act final Sheet firstSheet = unitUnderTest.createStandardExcelSheet(workbook, "FooBar", "FooBarTitle", columnTitles); final CellStyle cellStyle = unitUnderTest.getCellStyle(ExcelReportService.ExcelElement.CELL, workbook); for (int index = 2; index < 4; index++) { final Row theRow = firstSheet.createRow(index); theRow.setRowStyle(cellStyle); unitUnderTest.addCell(0, theRow, "Row_" + index + "_Cell0\n... and a Newline", cellStyle); unitUnderTest.addCell(1, theRow, "Row_" + index + "_Cell1\n... and a Newline", cellStyle); } final FileOutputStream outputStream = new FileOutputStream(targetFile); outputStream.write(unitUnderTest.convertToByteArray(workbook)); // Assert // // Read the document, and verify that cell values match ... ? }