ASF Bugzilla – Attachment 27634 Details for
Bug 48344
setRowStyle() method of HSSFRow is not working
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
TestRowStyle.java
TestRowStyle.java (text/plain), 3.36 KB, created by
Denis Kurochkin
on 2011-09-29 12:54:47 UTC
(
hide
)
Description:
TestRowStyle.java
Filename:
MIME Type:
Creator:
Denis Kurochkin
Created:
2011-09-29 12:54:47 UTC
Size:
3.36 KB
patch
obsolete
>import java.io.*; > >import org.apache.poi.hssf.usermodel.*; >import org.apache.poi.hssf.util.*; > > >public class TestRowStyle { > > /** > * @param args > * @throws IOException > */ > public static void main(String[] args) throws IOException { > > HSSFWorkbook workBook = new HSSFWorkbook(); > HSSFSheet sheet = workBook.createSheet("test"); > sheet.setColumnWidth(0, 255*40); > > HSSFFont font = workBook.createFont(); > font.setFontHeightInPoints((short) 12); > font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); > > HSSFCellStyle style = workBook.createCellStyle(); > style.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index); > style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); > style.setFont(font); > > HSSFRow row; > > // Test1 > row = sheet.createRow(2); > row.setRowStyle(style); > row.createCell(0).setCellValue("Test1, applying style before creating cells"); > > // Test2 > row = sheet.createRow(3); > row.createCell(0).setCellValue("Test2, applying style after creating cells"); > row.setRowStyle(style); > > // Test4 > row = sheet.createRow(4); > HSSFCell cell = row.createCell(0); > cell.setCellValue("Test3, applying style on single cell"); > cell.setCellStyle(style); > > // Test5 > sheet.createRow(5).createCell(0).setCellValue("Test5, another case of applying style on row"); > sheet.getRow(5).setRowStyle(style); > > FileOutputStream fileOut = new FileOutputStream("TestRowStyle.xls"); > workBook.write(fileOut); > fileOut.close(); > > testStyles(); > } > > public static void testStyles() throws IOException{ > FileInputStream f = new FileInputStream("TestRowStyle.xls"); > HSSFWorkbook workBook = new HSSFWorkbook(f); > HSSFSheet sheet = workBook.getSheet("test"); > > HSSFCellStyle style = sheet.getRow(2).getRowStyle(); > System.out.println("Row2 Color: " + style.getFillForegroundColorColor().getIndex()); > System.out.println("Row2 fontBoldWeight: " + style.getFont(workBook).getBoldweight()); > System.out.println("Row2 fontHeight: " + style.getFont(workBook).getFontHeightInPoints()); > style = sheet.getRow(2).getCell(0).getCellStyle(); > System.out.println("Cell0 in Row2 Color: " + style.getFillForegroundColorColor().getIndex()); > System.out.println("Cell0 in Row2 fontBoldWeight: " + style.getFont(workBook).getBoldweight()); > System.out.println("Cell0 in Row2 fontHeight: " + style.getFont(workBook).getFontHeightInPoints()); > style = sheet.getRow(3).getCell(0).getCellStyle(); > System.out.println("Cell0 in Row3 Color: " + style.getFillForegroundColorColor().getIndex()); > System.out.println("Cell0 in Row3 fontBoldWeight: " + style.getFont(workBook).getBoldweight()); > System.out.println("Cell0 in Row3 fontHeight: " + style.getFont(workBook).getFontHeightInPoints()); > style = sheet.getRow(4).getCell(0).getCellStyle(); > System.out.println("Cell0 in Row4 Color: " + style.getFillForegroundColorColor().getIndex()); > System.out.println("Cell0 in Row4 fontBoldWeight: " + style.getFont(workBook).getBoldweight()); > System.out.println("Cell0 in Row4 fontHeight: " + style.getFont(workBook).getFontHeightInPoints()); > style = sheet.getRow(5).getCell(0).getCellStyle(); > System.out.println("Cell0 in Row5 Color: " + style.getFillForegroundColorColor().getIndex()); > System.out.println("Cell0 in Row5 fontBoldWeight: " + style.getFont(workBook).getBoldweight()); > System.out.println("Cell0 in Row5 fontHeight: " + style.getFont(workBook).getFontHeightInPoints()); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 48344
:
27627
|
27628
|
27633
| 27634 |
38460
|
38461