public List <EisppImportEktte> GetEktteFromExcel(byte[] excelContent, int fromRow) { NPoiExcelService excelService = new NPoiExcelService(excelContent, 0); int row = fromRow; bool haveData = true; var ektteItems = new List <EisppImportEktte>(); while (haveData) { var item = new EisppImportEktte(); item.Row = row; excelService.rowIndex = row; excelService.colIndex = 0; item.Oblast = excelService.GetValue(); item.Obstina = excelService.GetValue(); item.TypeNM = excelService.GetValue(); item.Name = excelService.GetValue(); item.Rajon = excelService.GetValue(); item.SystemCode = excelService.GetValue(); item.SystemName = excelService.GetValue(); item.EktteCode = excelService.GetValue(); item.Active = excelService.GetValue(); item.DateFrom = excelService.GetValue(); item.DateTo = excelService.GetValue(); haveData = !string.IsNullOrEmpty(item.Oblast); if (haveData) { ektteItems.Add(item); } row++; } return(ektteItems); }
/// <summary> /// Справка за доказателства в ексел /// </summary> /// <param name="courtId"></param> /// <param name="model"></param> /// <returns></returns> public byte[] CaseEvidenceSpr_ToExcel(int courtId, CaseEvidenceSprFilterVM model) { var caseEvidenceSprs = CaseEvidenceSpr(courtId, model).OrderBy(x => x.DateAccept).ToList(); var htmlTemplate = repo.AllReadonly <HtmlTemplate>() .Where(x => x.Alias.ToUpper() == "Evidence".ToUpper()) .FirstOrDefault(); NPoiExcelService excelService = new NPoiExcelService(htmlTemplate.Content, 0); excelService.rowIndex = (htmlTemplate.XlsDataRow ?? 0) - 1; excelService.InsertList( caseEvidenceSprs, new List <Expression <Func <CaseEvidenceSprVM, object> > >() { x => x.RegNumber, x => x.DateAccept, x => x.FileNumber, x => x.CaseGroupLabel, x => x.CaseNumber, x => x.NamePodsydim, x => x.Description, x => x.MovementsDateSend, x => x.MovementsDateReceive, x => x.Movements } ); return(excelService.ToArray()); }
public List <EisppImportNomenclature> GetNomenclatureFromExcel(byte[] excelContent, int fromRow) { NPoiExcelService excelService = new NPoiExcelService(excelContent, 0); int row = fromRow; bool haveData = true; var nomItems = new List <EisppImportNomenclature>(); int blankRows = 0; string groupCode = string.Empty; while (blankRows < 10) { var item = new EisppImportNomenclature(); item.Row = row; excelService.rowIndex = row; excelService.colIndex = 0; item.GroupName = excelService.GetValue(); item.Name = excelService.GetValue(); item.SystemCode = excelService.GetValue(); item.SystemName = excelService.GetValue(); item.Active = excelService.GetValue(); item.DateFrom = excelService.GetValue(); item.DateTo = excelService.GetValue(); item.GroupCode = groupCode; haveData = !string.IsNullOrEmpty(item.GroupName) && !string.IsNullOrEmpty(item.SystemCode); if (haveData) { if (string.IsNullOrEmpty(item.Name)) { groupCode = item.SystemCode; item.GroupCode = null; } blankRows = 0; nomItems.Add(item); } else { blankRows++; } row++; } return(nomItems); }
public List <EisppImportCrimeQualification> GetCrimeQualificationFromExcel(byte[] excelContent, int fromRow) { NPoiExcelService excelService = new NPoiExcelService(excelContent, 0); int row = fromRow; bool haveData = true; var structureItems = new List <EisppImportCrimeQualification>(); int blankRows = 0; while (blankRows < 10) { var item = new EisppImportCrimeQualification(); item.Row = row; excelService.rowIndex = row; excelService.colIndex = 0; item.GroupName4 = excelService.GetValue(); item.GroupName3 = excelService.GetValue(); item.GroupName2 = excelService.GetValue(); item.Name = excelService.GetValue(); item.SystemCode = excelService.GetValue(); item.SystemName = excelService.GetValue(); item.Active = excelService.GetValue(); item.DateFrom = excelService.GetValue(); item.DateTo = excelService.GetValue(); haveData = !string.IsNullOrEmpty(item.Name) || !string.IsNullOrEmpty(item.SystemCode); if (haveData) { blankRows = 0; structureItems.Add(item); } else { blankRows++; } row++; } return(structureItems); }