mockworkbookcellfinder.java

来自「一个java生成自动生成Excel」· Java 代码 · 共 35 行

JAVA
35
字号
package net.sf.jxls;

import java.util.List;
import java.util.Map;

import net.sf.jxls.controller.WorkbookCellFinderImpl;

import org.apache.poi.hssf.util.CellReference;

/**
 * @author Leonid Vysochyn
 */
public class MockWorkbookCellFinder extends WorkbookCellFinderImpl {
    Map sheetCellsMapping;

    public MockWorkbookCellFinder(Map sheetCellsMapping) {
        this.sheetCellsMapping = sheetCellsMapping;
    }



    public List findCell(String sheetName, String cellName) {
        if( !sheetCellsMapping.containsKey( sheetName ) ){
            throw new IllegalArgumentException("Can't find sheet with name " + sheetName);
        }
        Map cellsMapping = (Map) sheetCellsMapping.get( sheetName );
        return (List) cellsMapping.get( cellName );
    }

    public List findCell(String sheetName, int rowNum, int colNum) {
        CellReference cellReference = new CellReference( rowNum, colNum );
        return findCell( sheetName, cellReference.toString() );
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?