Пример #1
0
        /// <summary>Read an Excel file into memory.</summary>
        /// <param name="inputStream">The workbook to read.</param>
        /// <param name="type">The version of file being read.</param>
        /// <returns>A facade over the specific Excel libraries.</returns>
        public static ExcelFile Read(System.IO.Stream inputStream, ExcelFileType type)
        {
            ExcelFile file;

            switch (type)
            {
            case ExcelFileType.XLS:
                file = new NpoiExcelFile(inputStream);
                break;

            case ExcelFileType.XLSX:
                file = new EPPlusExcelFile(inputStream);
                break;

            default:
                throw new InvalidOperationException();
            }
            return(file);
        }
Пример #2
0
        /// <summary>Create a new Workbook.</summary>
        /// <param name="type">The version of Excel to target.</param>
        /// <returns>A facade over the specific Excel libraries.</returns>
        public static ExcelFile Create(ExcelFileType type)
        {
            ExcelFile newFile;

            switch (type)
            {
            case ExcelFileType.XLS:
                newFile = new NpoiExcelFile();
                break;

            case ExcelFileType.XLSX:
                newFile = new EPPlusExcelFile();
                break;

            default:
                throw new InvalidOperationException();
            }
            return(newFile);
        }
Пример #3
0
 /// <summary>Read an Excel file into memory.</summary>
 /// <param name="inputStream">The workbook to read.</param>
 /// <param name="type">The version of file being read.</param>
 /// <returns>A facade over the specific Excel libraries.</returns>
 public static ExcelFile Read(System.IO.Stream inputStream, ExcelFileType type)
 {
     ExcelFile file;
     switch (type)
     {
         case ExcelFileType.XLS:
             file = new NpoiExcelFile(inputStream);
             break;
         case ExcelFileType.XLSX:
             file = new EPPlusExcelFile(inputStream);
             break;
         default:
             throw new InvalidOperationException();
     }
     return file;
 }
Пример #4
0
 /// <summary>Create a new Workbook.</summary>
 /// <param name="type">The version of Excel to target.</param>
 /// <returns>A facade over the specific Excel libraries.</returns>
 public static ExcelFile Create(ExcelFileType type)
 {
     ExcelFile newFile;
     switch (type)
     {
         case ExcelFileType.XLS:
             newFile = new NpoiExcelFile();
             break;
         case ExcelFileType.XLSX:
             newFile = new EPPlusExcelFile();
             break;
         default:
             throw new InvalidOperationException();
     }
     return newFile;
 }