using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ClosedXML.Excel; using AsbCloudApp.Data; namespace AsbCloudInfrastructure.Services { public class WellOperationImportService { private const string sheetNamePlan = "План"; private const string sheetNameFact = "Факт"; public IEnumerable ParseFile(string excelFilePath) { if (!File.Exists(excelFilePath)) throw new FileNotFoundException($"Файл {excelFilePath} не найден."); using var sourceExcelWorkbook = new XLWorkbook(excelFilePath, XLEventTracking.Disabled); var sheetPlan = sourceExcelWorkbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNamePlan); if (sheetPlan is null) throw new FileFormatException($"Файл {excelFilePath} не не содержит листа {sheetNamePlan}."); var sheetFact = sourceExcelWorkbook.Worksheets.FirstOrDefault(ws => ws.Name == sheetNameFact); if (sheetFact is null) throw new FileFormatException($"Файл {excelFilePath} не не содержит листа {sheetNameFact}."); var wellOperations = new List(); return wellOperations; } } }