net.sf.jxls.controller.WorkbookCellFinderImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jxls-core Show documentation
Show all versions of jxls-core Show documentation
jXLS is a small and easy-to-use Java library for generating Excel files using XLS templates
package net.sf.jxls.controller;
import org.apache.poi.hssf.util.CellReference;
import net.sf.jxls.controller.SheetCellFinder;
import net.sf.jxls.controller.WorkbookCellFinder;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
/**
* Simple implementation of {@link net.sf.jxls.controller.WorkbookCellFinder} based on SheetCellFinder mapping to corresponding worksheets
* @author Leonid Vysochyn
*/
public class WorkbookCellFinderImpl implements WorkbookCellFinder {
Map sheetCellFinderMapping = new HashMap();
public WorkbookCellFinderImpl() {
}
public WorkbookCellFinderImpl(Map sheetCellFinderMapping) {
this.sheetCellFinderMapping = sheetCellFinderMapping;
}
public List findCell(String sheetName, String cellName) {
CellReference cellReference = new CellReference( cellName );
int colNum = cellReference.getCol();
int rowNum = cellReference.getRow();
return findCell( sheetName, rowNum, colNum );
}
public List findCell(String sheetName, int rowNum, int colNum) {
if( !sheetCellFinderMapping.containsKey( sheetName ) ){
throw new IllegalArgumentException("Can't find sheet with name " + sheetName + " used in formula cell reference");
}
return ((SheetCellFinder)sheetCellFinderMapping.get( sheetName )).findCell( rowNum, colNum );
}
}