Package io.keikai.importer
Class XlsxImporter
java.lang.Object
io.keikai.range.impl.imexp.AbstractImporter
io.keikai.importer.XlsxImporter
- All Implemented Interfaces:
SImporter,Serializable
An excel xlsx importer
- Since:
- 5.0.0
- Author:
- jumperchen
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected io.keikai.importer.ImportPhaseprotected SBooktarget book modelstatic final StringA built-in defined name that specifies the workbook's print areastatic final StringA built-in defined name that specifies the row(s) or column(s) to repeat at the top of each printed page.static final int#DIV/0!static final intstatic final int#N/A - Argument or function not availablestatic final int#NAME?static final int#NULL!static final int#NUM!static final int#REF!static final int#VALUE!<poi Font index,SFontobject>protected Map<XlsxExtractor.XlsxXfExtractor,SCellStyle> protected StyleCacheFields inherited from class io.keikai.range.impl.imexp.AbstractImporter
_importCache, BOOK_TYPE_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected shortconvertToUIRotation(short rotation) protected static InputStreamprotected Borders.BordercreateBorder(XlsxExtractor.XlsxBorderExtractor extractor) protected Borders.BorderPrprotected SFontprotected SBordercreateSBorder(Borders.Border border) protected AbstractSeriesAdvcreateSeries(io.keikai.importer.SeriesJson json, SGeneralChartData chartData) protected SFontdoublegeDefaultColumnWidthPerBaseColWidth(int baseWidth, int charWidth) protected intgetAnchorHeightInPx(io.keikai.importer.ShapeJson shapeJson, SSheet sheet) DefaultBookWidgetLoader.getXSSFHeightInPx()protected intgetAnchorWidthInPx(io.keikai.importer.ShapeJson shapeJson, SSheet sheet) Reference DefaultBookWidgetLoader.getXSSFWidthInPx()static StringgetBackgroundHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter) static StringgetBorderHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter) static final bytegetErrorCode(String errorText) static final StringgetErrorText(int errorCode) static StringgetFontHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter) static StringgetForegroundHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter) protected static StringgetHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter, String nullAs) protected static StringgetHTMLColorFromHex(String colorHax) protected StringgetNumberFormat(XlsxExtractor.XlsxNumFmtExtractor extractor) protected shortgetPasswordHash(String password) protected static org.apache.poi.ss.util.CellRangeAddressgetRepeatingRowsOrColumns(String refs, boolean rows) protected static SColorgetSchemeHTMLColor(XlsxExtractor.XlsxSchemeClrExtractor color, XlsxExtractor.XlsxThemesExtractor themes) protected StringgetTitleFormula(io.keikai.importer.SeriesJson seriesJson) return a formula or generate a default title ("Series[N]")if title doesn't exist.protected doublegetXlsxDefaultColumnWidth(XlsxExtractor.XlsxSheetExtractor extractor, int charWidth) protected intgetXoffsetInPixel(io.keikai.importer.ShapeJson shapeJson) protected intgetYoffsetInPixel(io.keikai.importer.ShapeJson shapeJson) protected voidimportAutoFilter(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) protected voidimportAutoFilterColumns(XlsxExtractor.XlsxAutoFilterExtractor xFilter, SAutoFilter zssFilter) protected voidimportAxis(io.keikai.importer.ChartSpaceJson chartSpaceJson, SChart chart) protected voidimportBorders(List<XlsxExtractor.XlsxBorderExtractor> extractors) protected voidimportCategory(io.keikai.importer.CategorySeriesJson categorySeriesJson, SGeneralChartData chartData) protected voidimportCategorySeries(io.keikai.importer.CategorySeriesJson categorySeriesJson, SGeneralChartData chartData, boolean isLine, boolean checkSmooth) protected SCellimportCell(XlsxExtractor.XlsxCellExtractor xCell, int row, SSheet sheet) protected SCellStyleimportCellStyleXf(XlsxExtractor.XlsxXfExtractor xCellXf, boolean inStyleTable) protected SCellStyleimportCellXf(XlsxExtractor.XlsxXfExtractor xCellXf, boolean inStyleTable) protected voidimportChart(io.keikai.importer.ChartSpaceJson chartSpaceJson, XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) protected SColorFilterimportColorFilter(XlsxExtractor.XlsxColorFilterExtractor colorFilter) protected voidimportColors(XlsxExtractor.XlsxRGBColorsExtractor extractor) protected voidimportColumn(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) [ISO/IEC 29500-1 1st Edition] 18.3.1.13 col (Column Width & Formatting) By experiments, CT_Col is always created in ascending order by min and the range specified by min & max doesn't overlap each other.
For example: <x:cols xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <x:col min="1" max="1" width="11.28515625" customWidth="1" /> <x:col min="2" max="4" width="11.28515625" hidden="1" customWidth="1" /> <x:col min="5" max="5" width="11.28515625" customWidth="1" /> </x:cols>protected voidprotected voidimportConditionalFormatting(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet, List<XlsxExtractor.XlsxExtExtractor> extList) protected SCustomFiltersimportCustomFilters(XlsxExtractor.XlsxCustomFiltersExtractor xCustomFilters) protected voidprotected voidprotected voidimportDrawings(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) protected SDynamicFilterimportDynamicFilter(XlsxExtractor.XlsxDynamicFilterExtractor xDynamicFilter) protected voidimportExternalBookLinks(List<XlsxExtractor.XlsxExternalLinkExtractor> externalReferences) protected SExtraStyleprotected voidprotected voidimportFills(List<XlsxExtractor.XlsxFillExtractor> extractors) protected voidimportFonts(List<XlsxExtractor.XlsxFontExtractor> extractors) protected voidprotected voidimportMergedRegions(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) protected voidName should be created after sheets created.protected voidprotected voidimportNumFmts(List<XlsxExtractor.XlsxNumFmtExtractor> extractors) protected voidimportPassword(XlsxExtractor.XlsxSheetProtectionExtractor protectionExtractor, SSheet sheet) protected voidimportPicture(io.keikai.importer.PictureJson pictureJson, XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) protected voidimportPrintArea(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) protected voidimportRichText(XlsxExtractor.XlsxRichTextExtractor xRichText, SRichText richText) protected SRowimportRow(XlsxExtractor.XlsxRowExtractor xRow, SSheet sheet) imports(InputStream inputStream, String bookName) Import book from a input streamprotected voidimportSeries(io.keikai.importer.SeriesJson seriesJson, SGeneralChartData chartData) reference ChartHelper.prepareCategoryModel() Category normally indicates the values show on X axis.protected SSheetprotected voidimportSheetProtection(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) protected voidprotected voidimportSparklines(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet, List<XlsxExtractor.XlsxExtExtractor> extList) protected voidprotected voidimportTableName(STable table) protected voidimportTables(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) protected STableStyleprotected STableStyleElemprotected voidprotected STop10FilterimportTop10Filter(XlsxExtractor.XlsxTop10Extractor xTop10Filter) protected voidimportValidation(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet, List<XlsxExtractor.XlsxExtExtractor> extList) Reference BookHelper.validate()protected voidprotected voidprotected voidimportXySeries(io.keikai.importer.XYSeriesJson xySeriesJson, SGeneralChartData chartData) protected voidimportXyzSeries(io.keikai.importer.XYZSeriesJson xyzSeriesJson, SGeneralChartData chartData) reference ChartHelper.prepareXYZModel()protected booleanprotected XlsxExtractor.XlsxWorkbookExtractornewXlsxExtractor(InputStream inputStream) protected SCFIconprotected SColorScaleprotected ConditionalFormattingImplprotected ConditionalFormattingRuleImplprepareConditonalFormattingRuleImpl(SConditionalFormatting cfi, XlsxExtractor.XlsxCfRuleExtractor xRule) protected SDataBarprotected voidprotected SIconSetprotected SCFValueObjectprotected voidsetBookType(SBook book) protected booleanskipName(XlsxExtractor.XlsxDefinedNameExtractor definedName) protected inttoBarOverlap(io.keikai.importer.ChartTypeJson json, SChart.ChartGrouping chartGrouping) protected ValueAxisImpl.CrossBetweentoChartAxisCrossBetween(String crossBetween) protected AbstractChartAxisAdv.CrossestoChartAxisCrosses(String crosses) protected CategoryAxisImpl.LabelAligntoChartAxisLabelAlign(String labelAlign) protected AbstractChartAxisAdv.OrientationtoChartAxisOrientation(String orientation) protected AbstractChartAxisAdv.PositiontoChartAxisPosition(String legendPosition) protected AbstractChartAxisAdv.TickLabelPositiontoChartAxisTickLabelPosition(String tickLabelPosition) protected DateAxisImpl.TimeUnittoChartAxisTimeUnit(String timeUnit) toChartGrouping(String grouping) protected SChart.ChartLegendPositiontoChartLegendPosition(String legendPosition) protected SChart.ChartTypetoChartType(io.keikai.importer.ChartType chartType) protected SColortoColor(XlsxExtractor.XlsxColorExtractor extractor) protected SCellStyle.AlignmenttoHorizontalAlignment(String align) protected ViewAnchortoSparklineViewAnchor(String anchorRef, SSheet sheet) static SFont.TypeOffsettoTypeOffset(String typeOffset) static SFont.UnderlinetoUnderline(String underline) protected SCellStyle.VerticalAlignmenttoVerticalAlignment(String align) protected ViewAnchortoViewAnchor(io.keikai.importer.ShapeJson shapeJson, SSheet sheet) Methods inherited from class io.keikai.range.impl.imexp.AbstractImporter
imports, imports, isImportCache, setImportCache
-
Field Details
-
importedXfs
-
styleCaches
-
_importPhase
protected io.keikai.importer.ImportPhase _importPhase -
importedPictureJson
<poi Font index,SFontobject> -
book
target book model -
BUILTIN_PRINT_AREA
A built-in defined name that specifies the workbook's print area- See Also:
-
BUILTIN_PRINT_TITLE
A built-in defined name that specifies the row(s) or column(s) to repeat at the top of each printed page.- See Also:
-
ERROR_NULL
public static final int ERROR_NULL#NULL! - Intersection of two cell ranges is empty- See Also:
-
ERROR_DIV_0
public static final int ERROR_DIV_0#DIV/0! - Division by zero- See Also:
-
ERROR_VALUE
public static final int ERROR_VALUE#VALUE! - Wrong type of operand- See Also:
-
ERROR_REF
public static final int ERROR_REF#REF! - Illegal or deleted cell reference- See Also:
-
ERROR_NAME
public static final int ERROR_NAME#NAME? - Wrong function or range name- See Also:
-
ERROR_NUM
public static final int ERROR_NUM#NUM! - Value range overflow- See Also:
-
ERROR_NA
public static final int ERROR_NA#N/A - Argument or function not available- See Also:
-
ERROR_FORMULA
public static final int ERROR_FORMULA- See Also:
-
-
Constructor Details
-
XlsxImporter
public XlsxImporter()
-
-
Method Details
-
imports
Description copied from interface:SImporterImport book from a input stream- Specified by:
importsin interfaceSImporter- Parameters:
inputStream- the input streambookName- the book name for imported book- Returns:
- the book instance
- Throws:
IOException
-
importPrintArea
-
getRepeatingRowsOrColumns
protected static org.apache.poi.ss.util.CellRangeAddress getRepeatingRowsOrColumns(String refs, boolean rows) -
importHyperlinks
-
importVmlDrawing
-
importComments
-
importDefaultChartSeriesColors
protected void importDefaultChartSeriesColors() -
importStyleSheet
-
importColors
-
importNumFmts
-
importFonts
-
importFills
-
importBorders
-
createBorder
-
createBorderPr
-
importAutoFilter
-
importSheetProtection
-
importValidation
protected void importValidation(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet, List<XlsxExtractor.XlsxExtExtractor> extList) Reference BookHelper.validate() -
importMergedRegions
-
importSparklines
protected void importSparklines(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet, List<XlsxExtractor.XlsxExtExtractor> extList) -
toColor
-
toSparklineViewAnchor
-
importDrawings
-
importPicture
protected void importPicture(io.keikai.importer.PictureJson pictureJson, XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) -
toViewAnchor
-
getAnchorWidthInPx
Reference DefaultBookWidgetLoader.getXSSFWidthInPx() -
getAnchorHeightInPx
DefaultBookWidgetLoader.getXSSFHeightInPx() -
getXoffsetInPixel
protected int getXoffsetInPixel(io.keikai.importer.ShapeJson shapeJson) -
getYoffsetInPixel
protected int getYoffsetInPixel(io.keikai.importer.ShapeJson shapeJson) -
importChart
protected void importChart(io.keikai.importer.ChartSpaceJson chartSpaceJson, XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet) -
toChartGrouping
-
toBarOverlap
protected int toBarOverlap(io.keikai.importer.ChartTypeJson json, SChart.ChartGrouping chartGrouping) -
toChartLegendPosition
-
toChartAxisPosition
-
toChartAxisOrientation
-
toChartAxisTickLabelPosition
protected AbstractChartAxisAdv.TickLabelPosition toChartAxisTickLabelPosition(String tickLabelPosition) -
toChartAxisCrosses
-
toChartAxisLabelAlign
-
toChartAxisTimeUnit
-
toChartAxisCrossBetween
-
importCategory
protected void importCategory(io.keikai.importer.CategorySeriesJson categorySeriesJson, SGeneralChartData chartData) -
importSeries
reference ChartHelper.prepareCategoryModel() Category normally indicates the values show on X axis. Tile indicates the name for each series. -
createSeries
protected AbstractSeriesAdv createSeries(io.keikai.importer.SeriesJson json, SGeneralChartData chartData) -
importCategorySeries
protected void importCategorySeries(io.keikai.importer.CategorySeriesJson categorySeriesJson, SGeneralChartData chartData, boolean isLine, boolean checkSmooth) -
importXySeries
protected void importXySeries(io.keikai.importer.XYSeriesJson xySeriesJson, SGeneralChartData chartData) -
importXyzSeries
protected void importXyzSeries(io.keikai.importer.XYZSeriesJson xyzSeriesJson, SGeneralChartData chartData) reference ChartHelper.prepareXYZModel()- Parameters:
xyzSeriesJson-chartData-
-
importAxis
-
getTitleFormula
return a formula or generate a default title ("Series[N]")if title doesn't exist. reference ChartHelper.prepareTitle()- Parameters:
seriesJson-- Returns:
-
toChartType
-
importColumn
[ISO/IEC 29500-1 1st Edition] 18.3.1.13 col (Column Width & Formatting) By experiments, CT_Col is always created in ascending order by min and the range specified by min & max doesn't overlap each other.
For example: <x:cols xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <x:col min="1" max="1" width="11.28515625" customWidth="1" /> <x:col min="2" max="4" width="11.28515625" hidden="1" customWidth="1" /> <x:col min="5" max="5" width="11.28515625" customWidth="1" /> </x:cols> -
getXlsxDefaultColumnWidth
protected double getXlsxDefaultColumnWidth(XlsxExtractor.XlsxSheetExtractor extractor, int charWidth) -
geDefaultColumnWidthPerBaseColWidth
public double geDefaultColumnWidthPerBaseColWidth(int baseWidth, int charWidth) -
importRow
-
importCell
-
getErrorText
- Returns:
- Standard Excel error literal for the specified error code.
- Throws:
IllegalArgumentException- if the specified error code is not one of the 7 standard error codes
-
getErrorCode
-
mustCalc
-
importRichText
-
createDxfZssFont
-
createZssFont
-
getHTMLColorFromHex
-
getBorderHTMLColor
public static String getBorderHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter) -
getFontHTMLColor
public static String getFontHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter) -
getForegroundHTMLColor
public static String getForegroundHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter) -
getBackgroundHTMLColor
public static String getBackgroundHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter) -
getHTMLColor
protected static String getHTMLColor(XlsxExtractor.XlsxColorExtractor color, XlsxExtractor.XlsxThemesExtractor themes, XlsxImporter xlsxImporter, String nullAs) -
getSchemeHTMLColor
protected static SColor getSchemeHTMLColor(XlsxExtractor.XlsxSchemeClrExtractor color, XlsxExtractor.XlsxThemesExtractor themes) -
toUnderline
-
toTypeOffset
-
skipName
-
importNamedRange
protected void importNamedRange()Name should be created after sheets created. A special defined name, _xlnm._FilterDatabase (xlsx) or _FilterDatabase (xls), stores the selected cells for auto-filter -
convertZipInputStreamToInputStream
protected static InputStream convertZipInputStreamToInputStream(ZipInputStream in) throws IOException - Throws:
IOException
-
newXlsxExtractor
protected XlsxExtractor.XlsxWorkbookExtractor newXlsxExtractor(InputStream inputStream) throws IOException - Throws:
IOException
-
importDefaultCellStyles
-
getNumberFormat
-
toHorizontalAlignment
-
toVerticalAlignment
-
convertToUIRotation
protected short convertToUIRotation(short rotation) -
importCellStyleXf
-
importCellXf
-
importNamedStyles
-
importTables
-
importTableName
-
importColorFilter
-
importAutoFilterColumns
protected void importAutoFilterColumns(XlsxExtractor.XlsxAutoFilterExtractor xFilter, SAutoFilter zssFilter) -
importCustomFilters
protected SCustomFilters importCustomFilters(XlsxExtractor.XlsxCustomFiltersExtractor xCustomFilters) -
importDynamicFilter
protected SDynamicFilter importDynamicFilter(XlsxExtractor.XlsxDynamicFilterExtractor xDynamicFilter) -
importTop10Filter
-
importExtraStyles
-
importExtraStyle
-
createSBorder
-
importTableStyles
-
importTableStyleElem
protected STableStyleElem importTableStyleElem(XlsxExtractor.XlsxTableStyleElementExtractor styleElement) -
importTableStyle
-
setBookType
-
importExternalBookLinks
protected void importExternalBookLinks(List<XlsxExtractor.XlsxExternalLinkExtractor> externalReferences) -
importWorkbookProtection
-
importSheets
-
importSheet
-
importPassword
protected void importPassword(XlsxExtractor.XlsxSheetProtectionExtractor protectionExtractor, SSheet sheet) -
getPasswordHash
-
importConditionalFormatting
protected void importConditionalFormatting(XlsxExtractor.XlsxSheetExtractor xSheet, SSheet sheet, List<XlsxExtractor.XlsxExtExtractor> extList) -
prepareConditionalFormattingImpl
protected ConditionalFormattingImpl prepareConditionalFormattingImpl(SSheet sheet, XlsxExtractor.XlsxConditionalFormattingExtractor cf) -
prepareConditonalFormattingRuleImpl
protected ConditionalFormattingRuleImpl prepareConditonalFormattingRuleImpl(SConditionalFormatting cfi, XlsxExtractor.XlsxCfRuleExtractor xRule) -
prepareColorScale
-
prepareIconSet
-
prepareFormulas
protected void prepareFormulas(ConditionalFormattingRuleImpl cfri, XlsxExtractor.XlsxCfRuleExtractor xRule) -
prepareDataBar
-
prepareValueObject
-
prepareCFIcon
-