JxlsCell |
JxlsCell: a class to wrap and simplify the use of Apache POI Cell in the context of OpenXava
Usage:
JxlsWorkbook wb = new JxlsWorkbook("Test");
JxlsSheet sheet = wb.addSheet("Test");
JxlsCell cell = sheet.setValue(4, 4, 2);
cell.setSpan(2, 1).setHyperLink("http://www.openxava.org");
sheet.setValue(4, 5, "Test").setSpan(3, 1);
|
JxlsSheet |
JxlsSheet: a class to wrap and simplify the use of Apache POI Sheet in the context of OpenXava
Principle:
As per Excel, the rows and colums start at 1
Types of cells:
Date, Number, Formulas and Text
Formulas can be encoded as
Excel: A1, $A1, A$1, $A$1, R1C1 (R[-1]C1 is not implemented)
Jxls: R1C1, $R1C1, R1$C1, $R1$C1
and they can start with =
Usage:
JxlsWorkbook wb = new JxlsWorkbook("Test");
JxlsSheet sheet = wb.addSheet("Test");
sheet.setValue(3, 4, "Pi", wb.addStyle(TEXT).setAlign(CENTER).setBold());
sheet.setValue(4, 4, 3.141592654, wb.addStyle(FLOAT).setAllBorders(THIN_BORDER));
sheet.setFormula(4, 5, "=2*$R4$C4", wb.addStyle("##0.0000"));
sheet.setFormula(4, 6, "=2*R4C4", wb.addStyle("##0.000"));
|
JxlsStyle |
JxlsStyle: a class to wrap and simplify the use of Apache POI CellStyle in the context of OpenXava
Principle:
JxlsStyle should not be instantiated directly, but rather created through workbook.addStyle(style)
each setProperty returns the style so the setProperty's can be chained
Usage:
JxlsWorkbook wb = new JxlsWorkbook("Test");
JxlsSheet sheet = wb.addSheet("Test");
JxlsStyle boldCenteredTextS = wb.addStyle(TEXT).setAlign(CENTER).setBold();
JxlsStyle boldCenteredTextBorderedS = wb.addClonedStyle(boldCenteredTextS).setBorder(BOTTOM, BORDER_THIN);
sheet.setValue(3, 4, "Pi", boldCenteredTextS);
sheet.setValue(4, 4, "Pi", boldCenteredTextBorderedS);
|
JxlsWorkbook |
JxlsWorkbook: a class to wrap and simplify the use of Apache POI Workbook in the context of OpenXava
JxlsWorkbook's can be created:
- empty JxlsWorkbook wb = new JxlsWorkbook("Test");
- from a TableModel JxlsWorkbook wb = new JxlsWorkbook(tableModel, "Test");
- from an xls file JxlsWorkbook wb = new JxlsWorkbook(xlsFile);
Usage:
JxlsWorkbook wb = new JxlsWorkbook("Test");
JxlsSheet sheet = wb.addSheet("Test");
sheet.setValue(3, 4, "Pi", wb.addStyle(TEXT).setAlign(CENTER).setBold());
sheet.setValue(4, 4, 3.141592654, wb.addStyle(FLOAT).setAllBorders(THIN_BORDER));
sheet.setFormula(4, 5, "=2*$R4$C4", wb.addStyle("##0.0000"));
sheet.setFormula(4, 6, "=2*R4C4", wb.addStyle("##0.000"));
wb.write(new FileOutputStream("c:/Test.xls"));
Use of POI more advanced functionalities
JxlsWorkbook wb = new JxlsWorkbook("Test");
JxlsSheet sheet = wb.addSheet("Test");
sheet.setValue(3, 4, "Pi", wb.addStyle(TEXT).setAlign(CENTER).setBold());
Workbook poiWorkbook = wb.createPOIWorkbook();
// do an advanced function
poiWorkbook.write(new FileOutputStream("c:/Test.xls"));
|