private Supplier getFormatterForType ( String type ) { switch ( type ) { case "s" : //string stored in shared table if ( ! lastContents . isEmpty ( ) ) { int idx = Integer . parseInt ( lastContents ) ; return new StringSupplier ( new XSSFRichTextString ( sst . getEntryAt ( idx ) ) . toString ( ) ) ; } return new StringSupplier ( lastContents ) ; case "inlineStr" : //inline string (not in sst) case "str" : return new StringSupplier ( new XSSFRichTextString ( lastContents ) . toString ( ) ) ; case "e" : //error type return new StringSupplier ( "ERROR: " + lastContents ) ; case "n" : //numeric type if ( currentCell . getNumericFormat ( ) != null && lastContents . length ( ) > 0 ) { // the formatRawCellContents operation incurs a significant overhead on large sheets, // and we want to defer the execution of this method until the value is actually needed. // it is not needed in all cases.. final String currentLastContents = lastContents ; final int currentNumericFormatIndex = currentCell . getNumericFormatIndex ( ) ; final String currentNumericFormat = currentCell . getNumericFormat ( ) ; return new Supplier ( ) { String cachedContent ; @ Override public Object getContent ( ) { if ( cachedContent == null ) { cachedContent = dataFormatter . formatRawCellContents ( Double . parseDouble ( currentLastContents ) , currentNumericFormatIndex , currentNumericFormat ) ; } return cachedContent ; } } ; } else { return new StringSupplier ( lastContents ) ; } default : return new StringSupplier ( lastContents ) ; } }
Tries to format the contents of the last contents appropriately based on the provided type and the discovered numeric format .