public abstract class AbstractExcelImporter extends AbstractImporter implements Serializable
SBook
model including following information: Book: name Sheet: name,
(default) column width, (default) row height, hidden row (column), row
(column) style, freeze, merge, protection, named range , gridline display
Cell: type, value, font with color and style, type offset(normal or
subscript), background color, border's type and color , data format,
alignment, wrap, locked, fill pattern
We use XLSX, XLS common interface (e.g. CellStyle instead of
XSSFCellStyle
) to get content first for that codes can be easily
moved to parent class.Modifier and Type | Field and Description |
---|---|
protected boolean |
_importCache |
protected SBook |
book
target book model
|
protected static String |
BOOK_TYPE_KEY
book type key for book attribute
|
protected Map<Short,SFont> |
importedFont
SFont object> |
protected Map<PictureData,Integer> |
importedPictureData |
protected io.keikai.range.impl.imexp.AbstractExcelImporter.StyleCache |
importedStyle
Keep track of imported style during importing to avoid creating duplicated style objects.
|
protected Workbook |
workbook
source POI book
|
Constructor and Description |
---|
AbstractExcelImporter() |
Modifier and Type | Method and Description |
---|---|
protected abstract Workbook |
createPoiBook(InputStream is) |
protected SFont |
createZssFont(Font poiFont) |
protected abstract int |
getAnchorHeightInPx(ClientAnchor anchor,
Sheet poiSheet) |
protected abstract int |
getAnchorWidthInPx(ClientAnchor anchor,
Sheet poiSheet)
If in same column: anchorWidthInFirstColumn + anchor width in
inter-columns + anchorWidthInLastColumn (dx2) no in same column:
anchorWidthInLastColumn - offsetInFirstColumn (dx1)
|
static String |
getBookType(SBook book)
Gets the book-type information ("xls" or "xlsx"), return null if not found
|
protected Font |
getPoiFontFromRichText(Workbook book,
Cell cell,
RichTextString rstr,
int run) |
protected abstract int |
getXoffsetInPixel(ClientAnchor clientAnchor,
Sheet poiSheet) |
protected abstract int |
getYoffsetInPixel(ClientAnchor clientAnchor,
Sheet poiSheet) |
protected void |
importAutoFilter(Sheet poiSheet,
SSheet sheet)
POI AutoFilter.getFilterColumn(i) sometimes returns null.
|
protected void |
importAutoFilterColumns(AutoFilter poiFilter,
SAutoFilter zssFilter,
int numberOfColumn) |
protected SCell |
importCell(Cell poiCell,
int row,
SSheet sheet) |
protected SCellStyle |
importCellStyle(CellStyle poiCellStyle)
Convert CellStyle into NCellStyle
|
protected SCellStyle |
importCellStyle(CellStyle poiCellStyle,
boolean inStyleTable) |
protected abstract SColorFilter |
importColorFilter(ColorFilter colorFilter) |
protected abstract void |
importColumn(Sheet poiSheet,
SSheet sheet)
When a column is hidden with default width, we don't import the width for it's 0.
|
protected abstract void |
importConditionalFormatting(SSheet sheet,
Sheet poiSheet) |
protected abstract SCustomFilters |
importCustomFilters(CustomFilters customFilters) |
protected void |
importDefaultCellStyles() |
protected abstract void |
importDrawings(Sheet poiSheet,
SSheet sheet)
Drawings includes charts and pictures.
|
protected abstract SDynamicFilter |
importDynamicFilter(DynamicFilter dynamicFilter) |
protected abstract void |
importExternalBookLinks()
Excel uses external book links to map external book index and name.
|
protected void |
importExtraStyles() |
protected SFont |
importFont(CellStyle poiCellStyle) |
protected void |
importMergedRegions(Sheet poiSheet,
SSheet sheet) |
protected void |
importNamedRange()
Name should be created after sheets created.
|
protected void |
importNamedStyles() |
protected abstract void |
importPassword(Sheet poiSheet,
SSheet sheet) |
protected void |
importPicture(List<Picture> poiPictures,
Sheet poiSheet,
SSheet sheet) |
protected void |
importRichText(Cell poiCell,
RichTextString poiRichTextString,
SRichText richText) |
protected SRow |
importRow(Row poiRow,
SSheet sheet) |
SBook |
imports(InputStream is,
String bookName)
Import the model according to reversed dependency order among model
objects: book, sheet, defined name, cells, chart, pictures, validation.
|
protected SSheet |
importSheet(Sheet poiSheet,
int poiSheetIndex) |
protected void |
importSheetDefaultColumnWidth(Sheet poiSheet,
SSheet sheet) |
protected abstract void |
importSheetProtection(Sheet poiSheet,
SSheet sheet)
POI SheetProtection.
|
protected abstract void |
importTables(Sheet poiSheet,
SSheet sheet)
POI sheet tables
|
protected void |
importTableStyles() |
protected abstract STop10Filter |
importTop10Filter(Top10Filter top10Filter) |
protected abstract void |
importValidation(Sheet poiSheet,
SSheet sheet) |
protected boolean |
isImportCache()
Returns if import file cached value.
|
protected boolean |
mustCalc(SCell cell) |
protected abstract void |
setBookType(SBook book) |
void |
setImportCache(boolean b)
Set if import Excel cached value.
|
protected boolean |
skipName(Name definedName) |
protected ViewAnchor |
toViewAnchor(Sheet poiSheet,
ClientAnchor clientAnchor) |
protected SFont |
toZssFont(Font poiFont) |
imports, imports
protected io.keikai.range.impl.imexp.AbstractExcelImporter.StyleCache importedStyle
protected SBook book
protected Workbook workbook
protected Map<PictureData,Integer> importedPictureData
protected static String BOOK_TYPE_KEY
protected boolean _importCache
protected void importDefaultCellStyles()
protected void importNamedStyles()
public SBook imports(InputStream is, String bookName) throws IOException
imports
in interface SImporter
is
- the input streambookName
- the book name for imported bookIOException
protected abstract Workbook createPoiBook(InputStream is) throws IOException
IOException
protected abstract void setBookType(SBook book)
public static String getBookType(SBook book)
book
- protected abstract void importColumn(Sheet poiSheet, SSheet sheet)
poiSheet
- sheet
- protected abstract int getAnchorWidthInPx(ClientAnchor anchor, Sheet poiSheet)
protected abstract int getAnchorHeightInPx(ClientAnchor anchor, Sheet poiSheet)
protected void importNamedRange()
protected boolean skipName(Name definedName)
protected abstract void importExternalBookLinks()
protected void importSheetDefaultColumnWidth(Sheet poiSheet, SSheet sheet)
protected abstract void importDrawings(Sheet poiSheet, SSheet sheet)
protected void importRichText(Cell poiCell, RichTextString poiRichTextString, SRichText richText)
protected SCellStyle importCellStyle(CellStyle poiCellStyle)
poiCellStyle
- protected SCellStyle importCellStyle(CellStyle poiCellStyle, boolean inStyleTable)
protected ViewAnchor toViewAnchor(Sheet poiSheet, ClientAnchor clientAnchor)
protected abstract int getXoffsetInPixel(ClientAnchor clientAnchor, Sheet poiSheet)
protected abstract int getYoffsetInPixel(ClientAnchor clientAnchor, Sheet poiSheet)
protected void importAutoFilter(Sheet poiSheet, SSheet sheet)
poiSheet
- source POI sheetsheet
- destination sheetprotected void importAutoFilterColumns(AutoFilter poiFilter, SAutoFilter zssFilter, int numberOfColumn)
protected abstract STop10Filter importTop10Filter(Top10Filter top10Filter)
protected abstract SDynamicFilter importDynamicFilter(DynamicFilter dynamicFilter)
protected abstract SCustomFilters importCustomFilters(CustomFilters customFilters)
protected abstract SColorFilter importColorFilter(ColorFilter colorFilter)
protected Font getPoiFontFromRichText(Workbook book, Cell cell, RichTextString rstr, int run)
protected abstract void importSheetProtection(Sheet poiSheet, SSheet sheet)
poiSheet
- source POI sheetsheet
- destination sheetprotected abstract void importTables(Sheet poiSheet, SSheet sheet)
poiSheet
- source POI sheetsheet
- destination sheetpublic void setImportCache(boolean b)
setImportCache
in class AbstractImporter
protected boolean isImportCache()
isImportCache
in class AbstractImporter
protected boolean mustCalc(SCell cell)
protected abstract void importConditionalFormatting(SSheet sheet, Sheet poiSheet)
protected void importExtraStyles()
protected void importTableStyles()
Copyright © 2020. All rights reserved.