Example usage for org.apache.poi.xssf.model StylesTable getCellXfAt

List of usage examples for org.apache.poi.xssf.model StylesTable getCellXfAt

Introduction

In this page you can find the example usage for org.apache.poi.xssf.model StylesTable getCellXfAt.

Prototype

@Internal
    public CTXf getCellXfAt(int idx) 

Source Link

Usage

From source file:org.pentaho.di.trans.steps.excelinput.staxpoi.StaxPoiSheetTest.java

License:Apache License

private StylesTable mockStylesTable(final Map<Integer, Integer> styleToNumFmtId,
        final Map<Integer, String> numFmts) {
    StylesTable styles = mock(StylesTable.class);
    when(styles.getCellXfAt(any(Integer.class))).then(new Answer<CTXf>() {
        public CTXf answer(InvocationOnMock invocation) throws Throwable {
            int style = (int) invocation.getArguments()[0];
            Integer numFmtId = styleToNumFmtId.get(style);
            if (numFmtId != null) {
                CTXf ctxf = CTXf.Factory.newInstance();
                ctxf.setNumFmtId(numFmtId);
                return ctxf;
            } else {
                return null;
            }/*from  w w  w . j  a v  a 2s . com*/
        }
    });
    when(styles.getNumberFormatAt(any(Short.class))).then(new Answer<String>() {
        public String answer(InvocationOnMock invocation) throws Throwable {
            return numFmts.get(invocation.getArguments()[0]);
        }
    });
    return styles;
}