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

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

Introduction

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

Prototype

@Override
public String getNumberFormatAt(short fmtId) 

Source Link

Document

Get number format string given its id

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;
            }// w ww.  ja v a2 s .  co  m
        }
    });
    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;
}