/// <summary> /// Generate topic report. /// </summary> /// <param name="workbook">The npoi workbook interface.</param> /// <param name="sheet1">The npoi sheet interface.</param> /// <param name="rowIndex">The row target index.</param> /// <param name="model">The filter criteria value.</param> private void GenerateTopicReport(IWorkbook workbook, ISheet sheet1, ref int rowIndex, VendorEvaluationStatusReportRequestModel model) { IRow topicRow = sheet1.CreateRow(rowIndex); ExcelService.CreateTopicCell(workbook, sheet1, topicRow, 0, $"รายงานสถานะการประเมินผู้ขาย - วันที่พิมพ์ {UtilityService.DateTimeToStringTH(DateTime.Now, "dd MMM yyyy")}"); rowIndex = rowIndex + 1; IRow criteriaRow = sheet1.CreateRow(3); criteriaRow.Height = 3000; ExcelService.CreateCriteriaCell(workbook, sheet1, criteriaRow, 0, $"{this.GenerateCriteria(model)}"); ExcelService.SetCellCriteriaStyle(workbook, criteriaRow, 1, 3); rowIndex = rowIndex + 2; }
/// <summary> /// Generate header table. /// </summary> /// <param name="workbook">The npoi workbook interface.</param> /// <param name="sheet1">The npoi sheet interface.</param> /// <param name="rowIndex">The row target index.</param> /// <param name="maxCountUser">The max count user for generate dynamic header column.</param> /// <param name="model">The filter criteria value.</param> /// <returns></returns> private int GenerateHeaderTable(IWorkbook workbook, ISheet sheet1, ref int rowIndex, int maxCountUser, InvestigateEvaluationReportRequestModel model) { IRow topicRow = sheet1.CreateRow(rowIndex); ExcelService.CreateTopicCell(workbook, sheet1, topicRow, 0, $"รายงานตรวจสอบสถานะการประเมิน - วันที่พิมพ์ {UtilityService.DateTimeToStringTH(DateTime.Now, "dd MMM yyyy")}"); rowIndex = rowIndex + 1; IRow criteriaRow = sheet1.CreateRow(rowIndex); criteriaRow.Height = 3000; ExcelService.CreateCriteriaCell(workbook, sheet1, criteriaRow, 0, $"{this.GenerateCriteria(model)}"); ExcelService.SetCellCriteriaStyle(workbook, criteriaRow, 1, 3); rowIndex = rowIndex + 2; string[] mainHeaders = new string[] { "เลขที่ใบประเมิน", "บริษัท", "รอบการประเมิน", "รอบการประเมิน", "รหัสผู้ขาย", "ชื่อผู้ขาย", "ชื่อประเภทผู้ขาย", "ชื่อกลุ่มจัดซื้อ", "จำนวนผู้ประเมิน", "ประเมินแล้วเสร็จ", }; IRow headerRow = sheet1.CreateRow(rowIndex); headerRow.Height = 500; int cellHeaderIndex = 0; foreach (var item in mainHeaders) { ExcelService.SetCellHeaderStyle(workbook, headerRow, cellHeaderIndex); ExcelService.CreateHeaderCell(workbook, sheet1, headerRow, cellHeaderIndex, item); cellHeaderIndex++; } string[] userHeaders = new string[] { "ผู้ประเมิน", "สถานะ", "เหตุผล" }; for (int i = 0; i < maxCountUser; i++) { foreach (var item in userHeaders) { ExcelService.SetCellHeaderStyle(workbook, headerRow, cellHeaderIndex); ExcelService.CreateHeaderCell(workbook, sheet1, headerRow, cellHeaderIndex, item); sheet1.AddMergedRegion(new CellRangeAddress(5, 6, cellHeaderIndex, cellHeaderIndex)); cellHeaderIndex++; } } rowIndex++; IRow headerRow2 = sheet1.CreateRow(rowIndex); ExcelService.SetCellContentStyle(workbook, headerRow2, 0, cellHeaderIndex - 1); return(cellHeaderIndex); }