Package org.jzy3d.io.xls
Class ExcelBuilder
java.lang.Object
org.jzy3d.io.xls.ExcelBuilder
- All Implemented Interfaces:
IExcelBuilder
- Direct Known Subclasses:
ExcelBuilderMultiSheet
A utility wrapper around Apache POI Excel spreadsheet builder.
Comments only supported on XLS type (no XLSX)
To add new excel features, see
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.apache.poi.ss.usermodel.Font
static boolean
States if the builder should throw an IllegalArgumentException or simply warn with a log once a cell index exceed max number of columns or row.protected org.apache.poi.ss.usermodel.CreationHelper
protected int
protected org.apache.poi.ss.usermodel.Drawing
static int
static int
static int
The max number of columns supported by an excel sheet (256="IV" column header)static int
The max number of rows supported by an excel sheetprotected ExcelBuilder.Type
protected org.apache.poi.ss.usermodel.Workbook
-
Constructor Summary
ConstructorDescriptionExcelBuilder
(String workbookFile) ExcelBuilder
(org.apache.poi.ss.usermodel.Workbook workbook) ExcelBuilder
(ExcelBuilder.Type type, String firstSheetName) ExcelBuilder
(ExcelBuilder.Type type, String firstSheetName, org.apache.poi.ss.usermodel.Workbook workbook) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.poi.ss.usermodel.Comment
addComment
(org.apache.poi.ss.usermodel.Cell cell, String text, int row, int col, int colWidth, int rowHeight) org.apache.poi.ss.usermodel.Comment
buildComment
(String text, int row, int col, int colWidth, int rowHeight) Return a Comment.Collection<org.apache.poi.ss.usermodel.Sheet>
org.apache.poi.ss.usermodel.Font
org.apache.poi.ss.usermodel.Cell
getCell
(int i, int j) org.apache.poi.hssf.util.HSSFColor
getColor
(byte r, byte g, byte b) org.apache.poi.hssf.util.HSSFColor
org.apache.poi.ss.usermodel.CreationHelper
org.apache.poi.ss.usermodel.Sheet
int
org.apache.poi.hssf.usermodel.HSSFWorkbook
org.apache.poi.ss.usermodel.Cell
getOrCreateCell
(int i, int j) protected org.apache.poi.ss.usermodel.Row
getOrCreateRow
(int i) org.apache.poi.ss.usermodel.Sheet
org.apache.poi.ss.usermodel.Workbook
org.apache.poi.xssf.usermodel.XSSFWorkbook
static org.apache.poi.ss.usermodel.Workbook
static org.apache.poi.ss.usermodel.Workbook
int
loadPicture
(String image) loadStyleSheet
(String sheetName) void
mergeRange
(int firstRow, int firstColumn, int lastRow, int lastColumn) org.apache.poi.ss.usermodel.CellStyle
Return a new cell style instance for the choosen workbookExcelBuilder.Type
.org.apache.poi.ss.usermodel.CellStyle
newColoredCellStyle
(org.apache.poi.ss.usermodel.IndexedColors color) org.apache.poi.ss.usermodel.CellStyle
newColoredCellStyle
(ByteColor color) org.apache.poi.ss.usermodel.Font
newFont
(int size) int
org.apache.poi.ss.usermodel.Sheet
void
void
void
setActiveSheet
(int order) Set currently displayed sheet (different fromsetCurrentSheet(java.lang.String)
).org.apache.poi.ss.usermodel.Cell
setCell
(int row, int column, double value) org.apache.poi.ss.usermodel.Cell
setCell
(int row, int column, double value, org.apache.poi.ss.usermodel.CellStyle style) org.apache.poi.ss.usermodel.Cell
Set a cell text content with no styling information.org.apache.poi.ss.usermodel.Cell
Set a cell content at the given indices, and apply the style if it is not null.org.apache.poi.ss.usermodel.Cell
setCellFormula
(int row, int column, String formula) void
setColumnWidth
(int column, int width) Set the width (in units of 1/256th of a character width)void
setColumnWidthAuto
(int column) org.apache.poi.ss.usermodel.Sheet
setCurrentSheet
(String name) void
setCurrentSheet
(org.apache.poi.ss.usermodel.Sheet s) Set current Sheet in which cell are set.void
setCurrentSheetId
(int s) void
setFreezePane
(int colSplit, int rowSplit) void
setFreezePane
(int colSplit, int rowSplit, int leftmostColumn, int topRow) void
setHyperlink
(org.apache.poi.ss.usermodel.Cell cell, String link) void
setPicture
(int pictureIdx, int col1, int row1, boolean resize) void
setRowHeight
(int row, int height) void
setSheetOrder
(String name, int order) void
setSplitPane
(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane) protected boolean
sheetInitialized
(int index) protected boolean
validateCellIndex
(int row, int column, String content) Validate a cell index.
-
Field Details
-
MAX_COLUMN
public static int MAX_COLUMNThe max number of columns supported by an excel sheet (256="IV" column header) -
MAX_ROW
public static int MAX_ROWThe max number of rows supported by an excel sheet -
LAST_COLUMN
public static int LAST_COLUMN -
LAST_ROW
public static int LAST_ROW -
CRASH_ON_CELL_OVERFLOW
public static boolean CRASH_ON_CELL_OVERFLOWStates if the builder should throw an IllegalArgumentException or simply warn with a log once a cell index exceed max number of columns or row. -
type
-
workbook
protected org.apache.poi.ss.usermodel.Workbook workbook -
create
protected org.apache.poi.ss.usermodel.CreationHelper create -
drawing
protected org.apache.poi.ss.usermodel.Drawing drawing -
boldFont
protected org.apache.poi.ss.usermodel.Font boldFont -
currentSheetId
protected int currentSheetId -
sheets
-
-
Constructor Details
-
ExcelBuilder
public ExcelBuilder() -
ExcelBuilder
-
ExcelBuilder
-
ExcelBuilder
public ExcelBuilder(ExcelBuilder.Type type, String firstSheetName, org.apache.poi.ss.usermodel.Workbook workbook) -
ExcelBuilder
- Throws:
IOException
-
ExcelBuilder
public ExcelBuilder(org.apache.poi.ss.usermodel.Workbook workbook)
-
-
Method Details
-
getWorkbook
public org.apache.poi.ss.usermodel.Workbook getWorkbook()- Specified by:
getWorkbook
in interfaceIExcelBuilder
-
getHSSFWorkbook
public org.apache.poi.hssf.usermodel.HSSFWorkbook getHSSFWorkbook() -
getXSSFWorkbook
public org.apache.poi.xssf.usermodel.XSSFWorkbook getXSSFWorkbook() -
setCell
public org.apache.poi.ss.usermodel.Cell setCell(int row, int column, String content, org.apache.poi.ss.usermodel.CellStyle style) Set a cell content at the given indices, and apply the style if it is not null. If row(i) does not exist yet, it is created, otherwise it is recycled. If cell(i,j) does not exist yet, it is created, otherwise it is recycled. Reminder: excel support a maximum of 65,536 rows and 256 columns per sheet- Specified by:
setCell
in interfaceIExcelBuilder
- Parameters:
row
- row indexcolumn
- column indexcontent
- a string to display in the cellstyle
- a style to apply to the cell- Returns:
- the created or retrieved cell in case additional stuff should be done on it.
-
validateCellIndex
Validate a cell index. If cell index is out of maximum number of rows/columns:- throws an
IllegalArgumentException
ifCRASH_ON_CELL_OVERFLOW
is set to true. - otherwise emit a log warning and return false to invalidate this cell.
- throws an
-
setCell
Set a cell text content with no styling information.- Specified by:
setCell
in interfaceIExcelBuilder
-
setCellFormula
- Specified by:
setCellFormula
in interfaceIExcelBuilder
-
setCell
public org.apache.poi.ss.usermodel.Cell setCell(int row, int column, double value) - Specified by:
setCell
in interfaceIExcelBuilder
-
setCell
public org.apache.poi.ss.usermodel.Cell setCell(int row, int column, double value, org.apache.poi.ss.usermodel.CellStyle style) - Specified by:
setCell
in interfaceIExcelBuilder
-
setHyperlink
-
getSheet
-
setCurrentSheet
-
getCurrentSheet
public org.apache.poi.ss.usermodel.Sheet getCurrentSheet()- Specified by:
getCurrentSheet
in interfaceIExcelBuilder
-
getCurrentSheetId
public int getCurrentSheetId()- Specified by:
getCurrentSheetId
in interfaceIExcelBuilder
-
setCurrentSheetId
public void setCurrentSheetId(int s) - Specified by:
setCurrentSheetId
in interfaceIExcelBuilder
-
setCurrentSheet
public void setCurrentSheet(org.apache.poi.ss.usermodel.Sheet s) Set current Sheet in which cell are set. Different fromsetActiveSheet(int)
. -
setSheetOrder
-
setActiveSheet
public void setActiveSheet(int order) Set currently displayed sheet (different fromsetCurrentSheet(java.lang.String)
). -
newSheet
- Specified by:
newSheet
in interfaceIExcelBuilder
-
newSheet
-
getAllSheets
- Specified by:
getAllSheets
in interfaceIExcelBuilder
-
getAllSheetNames
-
sheetInitialized
protected boolean sheetInitialized(int index) -
setRowHeight
public void setRowHeight(int row, int height) - Specified by:
setRowHeight
in interfaceIExcelBuilder
-
setColumnWidth
public void setColumnWidth(int column, int width) Set the width (in units of 1/256th of a character width)- Specified by:
setColumnWidth
in interfaceIExcelBuilder
-
setColumnWidthAuto
public void setColumnWidthAuto(int column) - Specified by:
setColumnWidthAuto
in interfaceIExcelBuilder
-
setFreezePane
public void setFreezePane(int colSplit, int rowSplit) - Specified by:
setFreezePane
in interfaceIExcelBuilder
-
setFreezePane
public void setFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow) - Specified by:
setFreezePane
in interfaceIExcelBuilder
-
setSplitPane
public void setSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane) - Specified by:
setSplitPane
in interfaceIExcelBuilder
-
mergeRange
public void mergeRange(int firstRow, int firstColumn, int lastRow, int lastColumn) - Specified by:
mergeRange
in interfaceIExcelBuilder
-
newCellStyle
public org.apache.poi.ss.usermodel.CellStyle newCellStyle()Return a new cell style instance for the choosen workbookExcelBuilder.Type
.- Specified by:
newCellStyle
in interfaceIExcelBuilder
-
getOrCreateCell
public org.apache.poi.ss.usermodel.Cell getOrCreateCell(int i, int j) -
getCell
public org.apache.poi.ss.usermodel.Cell getCell(int i, int j) -
getOrCreateRow
protected org.apache.poi.ss.usermodel.Row getOrCreateRow(int i) -
addComment
public org.apache.poi.ss.usermodel.Comment addComment(org.apache.poi.ss.usermodel.Cell cell, String text, int row, int col, int colWidth, int rowHeight) - Specified by:
addComment
in interfaceIExcelBuilder
-
buildComment
public org.apache.poi.ss.usermodel.Comment buildComment(String text, int row, int col, int colWidth, int rowHeight) Return a Comment. Comments are supported only on XLS file (HSSF framework).- Parameters:
row
-col
-colWidth
-rowHeight
-- Returns:
-
newColoredCellStyle
- Specified by:
newColoredCellStyle
in interfaceIExcelBuilder
-
newColoredCellStyle
public org.apache.poi.ss.usermodel.CellStyle newColoredCellStyle(org.apache.poi.ss.usermodel.IndexedColors color) - Specified by:
newColoredCellStyle
in interfaceIExcelBuilder
-
getColor
- Specified by:
getColor
in interfaceIExcelBuilder
-
getColor
public org.apache.poi.hssf.util.HSSFColor getColor(byte r, byte g, byte b) -
loadPicture
- Specified by:
loadPicture
in interfaceIExcelBuilder
- Throws:
IOException
-
setPicture
public void setPicture(int pictureIdx, int col1, int row1, boolean resize) - Specified by:
setPicture
in interfaceIExcelBuilder
-
getBoldFont
public org.apache.poi.ss.usermodel.Font getBoldFont()- Specified by:
getBoldFont
in interfaceIExcelBuilder
-
newFont
public org.apache.poi.ss.usermodel.Font newFont(int size) - Specified by:
newFont
in interfaceIExcelBuilder
-
save
- Specified by:
save
in interfaceIExcelBuilder
- Throws:
IOException
-
save
- Specified by:
save
in interfaceIExcelBuilder
- Throws:
IOException
-
load
- Throws:
IOException
-
load
- Throws:
IOException
-
loadStyleSheet
-
getCreationHelper
public org.apache.poi.ss.usermodel.CreationHelper getCreationHelper()
-