Java Code Examples for com.alibaba.excel.metadata.CellData#getStringValue()
The following examples show how to use
com.alibaba.excel.metadata.CellData#getStringValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnumExcelConverter.java From easyexcel-utils with Apache License 2.0 | 6 votes |
@Override public Enum convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { String cellDataStr = cellData.getStringValue(); EnumFormat annotation = contentProperty.getField().getAnnotation(EnumFormat.class); Class enumClazz = annotation.value(); String[] fromExcel = annotation.fromExcel(); String[] toJavaEnum = annotation.toJavaEnum(); Enum anEnum = null; if (ArrayUtils.isNotEmpty(fromExcel) && ArrayUtils.isNotEmpty(toJavaEnum)) { Assert.isTrue(fromExcel.length == toJavaEnum.length, "fromExcel 与 toJavaEnum 的长度必须相同"); for (int i = 0; i < fromExcel.length; i++) { if (Objects.equals(fromExcel[i], cellDataStr)) { anEnum = EnumUtils.getEnum(enumClazz, toJavaEnum[i]); } } } else { anEnum = EnumUtils.getEnum(enumClazz, cellDataStr); } Assert.notNull(anEnum, "枚举值不合法"); return anEnum; }
Example 2
Source File: DisabledConverter.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
@Override public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { String stringValue = cellData.getStringValue(); if (ENABLE.equals(stringValue.trim())){ return 0; }else { return 1; } }
Example 3
Source File: DeleteConverter.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
@Override public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { String stringValue = cellData.getStringValue(); if (DELETE.equals(stringValue)){ return 1; }else { return 0; } }
Example 4
Source File: DisabledConverter.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
@Override public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { String stringValue = cellData.getStringValue(); if (ENABLE.equals(stringValue.trim())){ return 0; }else { return 1; } }
Example 5
Source File: DeleteConverter.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
@Override public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { String stringValue = cellData.getStringValue(); if (DELETE.equals(stringValue)){ return 1; }else { return 0; } }
Example 6
Source File: DisabledConverter.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
@Override public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { String stringValue = cellData.getStringValue(); if (ENABLE.equals(stringValue.trim())){ return 0; }else { return 1; } }
Example 7
Source File: DeleteConverter.java From fw-spring-cloud with Apache License 2.0 | 5 votes |
@Override public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { String stringValue = cellData.getStringValue(); if (DELETE.equals(stringValue)){ return 1; }else { return 0; } }
Example 8
Source File: CellInlineStringValueTagHandler.java From easyexcel with Apache License 2.0 | 5 votes |
@Override protected void setStringValue(XlsxReadContext xlsxReadContext) { // This is a special form of string CellData tempCellData = xlsxReadContext.xlsxReadSheetHolder().getTempCellData(); XSSFRichTextString richTextString = new XSSFRichTextString(tempCellData.getStringValue()); tempCellData.setStringValue(richTextString.toString()); }
Example 9
Source File: AbstractCellValueTagHandler.java From easyexcel with Apache License 2.0 | 5 votes |
@Override public void endElement(XlsxReadContext xlsxReadContext, String name) { XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder(); CellData tempCellData = xlsxReadSheetHolder.getTempCellData(); StringBuilder tempData = xlsxReadSheetHolder.getTempData(); CellDataTypeEnum oldType = tempCellData.getType(); switch (oldType) { case DIRECT_STRING: case STRING: case ERROR: tempCellData.setStringValue(tempData.toString()); break; case BOOLEAN: tempCellData.setBooleanValue(BooleanUtils.valueOf(tempData.toString())); break; case NUMBER: case EMPTY: tempCellData.setType(CellDataTypeEnum.NUMBER); tempCellData.setNumberValue(new BigDecimal(tempData.toString())); break; default: throw new IllegalStateException("Cannot set values now"); } // set string value setStringValue(xlsxReadContext); if (tempCellData.getStringValue() != null && xlsxReadContext.currentReadHolder().globalConfiguration().getAutoTrim()) { tempCellData.setStringValue(tempCellData.getStringValue()); } tempCellData.checkEmpty(); xlsxReadSheetHolder.getCellMap().put(xlsxReadSheetHolder.getColumnIndex(), tempCellData); }
Example 10
Source File: StringStringConverter.java From easyexcel with Apache License 2.0 | 4 votes |
@Override public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { return cellData.getStringValue(); }
Example 11
Source File: StringErrorConverter.java From easyexcel with Apache License 2.0 | 4 votes |
@Override public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { return cellData.getStringValue(); }
Example 12
Source File: CustomStringStringConverter.java From easyexcel with Apache License 2.0 | 2 votes |
/** * 这里是读的时候会调用 不用管 * * @param cellData * NotNull * @param contentProperty * Nullable * @param globalConfiguration * NotNull * @return */ @Override public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { return cellData.getStringValue(); }
Example 13
Source File: CustomStringStringConverter.java From easyexcel with Apache License 2.0 | 2 votes |
/** * 这里读的时候会调用 * * @param cellData * NotNull * @param contentProperty * Nullable * @param globalConfiguration * NotNull * @return */ @Override public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { return "自定义:" + cellData.getStringValue(); }