package org.fool.glorious.excel;

import org.fool.glorious.excel.service.ExcelService;
import org.fool.glorious.excel.service.impl.XlsService;
import org.fool.glorious.excel.service.impl.XlsxService;

public class ExcelServiceFactory {

    static public ExcelService newInstance(String path) {
        if (path.endsWith(ExcelService.SUF_XLS)) {
            return new XlsService(path);
        } else if (path.endsWith(ExcelService.SUF_XLSX)) {
            return new XlsxService(path);
        } else {
            throw new IllegalArgumentException("Only files with extension \".xls\" or \".xlsx\" are acceptable.");
        }
    }
}
