Пример #1
0
        private static void AssertSheetExists(string excelFileName, string sheetName)
        {
            ExcelSheetInfoProvider sheetInfoProvider = new ExcelSheetInfoProvider(excelFileName);

            if (!sheetInfoProvider.IsSheetPresent(sheetName))
            {
                throw new Exception(sheetName + ": sheet does not exist");
            }
        }
Пример #2
0
 public ExcelReader(string filename, string sheetName, ILogger logger)
 {
     _logger   = logger;
     FileName  = filename;
     SheetName = sheetName;
     AssertSheetExists(filename, sheetName);
     _stream  = ExcelSheetInfoProvider.GetFileStream(filename);
     _package = new ExcelPackage(_stream);
     _sheet   = _package.Workbook.Worksheets[sheetName];
 }
 private void OnInputFileChanged()
 {
     SelectedSheet = String.Empty;
     IsValid       = false;
     try
     {
         ExcelSheetInfoProvider sheetInfoProvider = new ExcelSheetInfoProvider(InputFileName);
         SheetNames = sheetInfoProvider.GetSheetNames();
     }
     catch (Exception)
     {
         SheetNames = new List <string>();
     }
 }
 public static bool IsSheetPresent(this ExcelSheetInfoProvider infoProvider, string sheetName)
 {
     return(infoProvider.GetSheetNames().Select(x => x.ToLower()).Contains(sheetName.ToLower()));
 }