Пример #1
0
 private void checkForWorksheetsPresent()
 {
     if (!Worksheets.Any())
     {
         throw new InvalidOperationException("Workbooks need at least one worksheet.");
     }
 }
Пример #2
0
        public Boolean TryGetWorksheet(String name, out IXLWorksheet worksheet)
        {
            if (Worksheets.Any(w => string.Equals(w.Name, XLWorksheets.TrimSheetName(name), StringComparison.OrdinalIgnoreCase)))
            {
                worksheet = Worksheet(name);
                return(true);
            }

            worksheet = null;
            return(false);
        }
Пример #3
0
        public Boolean TryGetWorksheet(String name, out IXLWorksheet worksheet)
        {
            if (Worksheets.Any(w => w.Name.ToLower().Equals(name.ToLower())))
            {
                worksheet = Worksheet(name);
                return(true);
            }

            worksheet = null;
            return(false);
        }
        public bool AddWorksheet(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                _logger.Error($"Undefined or empty worksheet name");
                return(false);
            }

            if (Worksheets.Any(w => w.Sheet.SheetName.Equals(name, StringComparison.OrdinalIgnoreCase)))
            {
                _logger.Error($"Duplicate worksheet name '{name}'");
                return(false);
            }

            Worksheets.Add(new ExcelSheet(_workbook.CreateSheet(name), _loggerFactory));

            return(true);
        }
Пример #5
0
 public bool HasWorksheet(string name)
 {
     return(Worksheets.Any(sheetName => sheetName.Equals(name, StringComparison.OrdinalIgnoreCase)));
 }