001    package railo.runtime.poi;
002    
003    import railo.runtime.exp.CasterException;
004    
005    public class ExcelUtil {
006    
007            public static short format(String strFormat, short defaultValue){
008                    strFormat=strFormat.trim().toUpperCase();
009                    if("XSSF".equals(strFormat)) return Excel.FORMAT_XSSF;
010                    if("HSSF".equals(strFormat)) return Excel.FORMAT_HSSF;
011                    return defaultValue;
012            }
013            
014            public static String format(short format, String defaultValue){
015                    if(Excel.FORMAT_XSSF==format) return "XSSF";
016                    if(Excel.FORMAT_HSSF==format) return "HSSF";
017                    return defaultValue;
018            }
019    
020            public static Excel toExcel(Object obj,Excel defaultValue) {
021                    if(obj instanceof Excel) return (Excel) obj;
022                    return defaultValue;
023            }
024    
025            public static Excel toExcel(Object obj) throws CasterException {
026                    if(obj instanceof Excel) return (Excel) obj;
027                    throw new CasterException(obj,"Excel");
028            }
029    }