com.github.kunalk16.excel.factory.CellValueFactory 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.model.jaxb.sharedstrings.SIType;
import com.github.kunalk16.excel.model.jaxb.sharedstrings.SharedStringType;
import com.github.kunalk16.excel.model.jaxb.worksheet.CellType;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
public class CellValueFactory {
private static final String STRING_MARKER = "s";
static String create(SharedStringType sharedStrings, CellType cell) {
List listOfSharedStrings = getListOfSharedStrings(sharedStrings);
return Optional.of(cell)
.filter(CellValueFactory::checkCellOfTypeString)
.map(CellType::getValue)
.map(Integer::parseInt)
.map(listOfSharedStrings::get)
.map(SIType::getValue)
.orElse(cell.getValue());
}
private static List getListOfSharedStrings(SharedStringType sharedStrings) {
return Optional.ofNullable(sharedStrings)
.map(SharedStringType::getSiTypeList)
.orElse(Collections.emptyList());
}
private static boolean checkCellOfTypeString(CellType cell) {
return Optional.of(cell)
.map(CellType::getType)
.map(STRING_MARKER::equals)
.orElse(false);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy