コード例 #1
0
        public static IWorkbook Create(string fileName)
        {
            if (ExcelCom.IsExcel2007(fileName))
            {
                return(new XSSFWorkbook());
            }

            if (ExcelCom.IsExcel2003(fileName))
            {
                return(new HSSFWorkbook());
            }

            return(null);
        }
コード例 #2
0
        public static IWorkbook CreateInputWorkbook(string fileName)
        {
            using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                if (ExcelCom.IsExcel2007(fileName))
                {
                    return(new XSSFWorkbook(fileStream));
                }

                if (ExcelCom.IsExcel2003(fileName))
                {
                    return(new HSSFWorkbook(fileStream));
                }
            }

            return(null);
        }