com.github.kunalk16.excel.factory.CellFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lightExcelReader Show documentation
Show all versions of lightExcelReader Show documentation
A lightweight Java framework to read .xlsx excel files.
package com.github.kunalk16.excel.factory;
import com.github.kunalk16.excel.factory.extractor.CellPositionDataExtractor;
import com.github.kunalk16.excel.model.factory.ExcelCell;
import com.github.kunalk16.excel.model.jaxb.sharedstrings.SharedStringType;
import com.github.kunalk16.excel.model.jaxb.worksheet.CellType;
import com.github.kunalk16.excel.model.user.Cell;
import java.util.function.IntPredicate;
class CellFactory {
static Cell create(SharedStringType sharedStrings, CellType cell) {
int row = getCellRow(cell);
String column = getCellColumn(cell);
String value = getValue(sharedStrings, cell);
return new ExcelCell(row, column, value);
}
private static int getCellRow(CellType cell) {
return Integer.parseInt(getCellPositionData(Character::isDigit, cell));
}
private static String getCellColumn(CellType cell) {
return getCellPositionData(Character::isAlphabetic, cell);
}
private static String getCellPositionData(IntPredicate predicate, CellType cell) {
return new CellPositionDataExtractor().apply(predicate, cell);
}
private static String getValue(SharedStringType sharedStrings, CellType cell) {
return CellValueFactory.create(sharedStrings, cell);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy