diff --git a/Tiobon.Core.Api/wwwroot/files/ExcelTemplate/1907723940382511104.xlsx b/Tiobon.Core.Api/wwwroot/files/ExcelTemplate/1907723940382511104.xlsx deleted file mode 100644 index a617ede0..00000000 Binary files a/Tiobon.Core.Api/wwwroot/files/ExcelTemplate/1907723940382511104.xlsx and /dev/null differ diff --git a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs index 2a8ba504..806c2cab 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs @@ -1,4 +1,6 @@ using NPOI.SS.UserModel; +using NPOI.SS.Util; +using static Tiobon.Core.DataAccess.ReportHelper; using static Tiobon.Core.Model.Consts; namespace Tiobon.Core.Services; @@ -398,6 +400,51 @@ public class Ghre_PlanServices : BaseServices().Select(x => new + { + x.DeptID, + x.DeptName + }).ToListAsync(); + + //var courses = await Db.Queryable().Select(x => new + //{ + // x.Id, + // x.CourseName + //}).ToListAsync(); + + var schools = await Db.Queryable().Select(x => new + { + x.Id, + x.SchoolName + }).ToListAsync(); + + int sheetIndex = hssfworkbook.GetSheetIndex("培训计划"); + if (sheetIndex >= 0) + { + sheet = hssfworkbook.GetSheetAt(sheetIndex); + + //设置数据源的值 + IDataValidationConstraint dvConstraint1 = sheet.GetDataValidationHelper().CreateExplicitListConstraint(items.Select(x => x.ParaDetailName).ToArray()); + //设置编辑的区域 + IDataValidation dataValidation1 = sheet.GetDataValidationHelper().CreateValidation(dvConstraint1, new CellRangeAddressList(1, 65535, 2, 2)); + sheet.AddValidationData(dataValidation1); + + dvConstraint1 = sheet.GetDataValidationHelper().CreateExplicitListConstraint(depts.Select(x => x.DeptName).ToArray()); + //设置编辑的区域 + dataValidation1 = sheet.GetDataValidationHelper().CreateValidation(dvConstraint1, new CellRangeAddressList(1, 65535, 1, 1)); + sheet.AddValidationData(dataValidation1); + + //dvConstraint1 = sheet.GetDataValidationHelper().CreateExplicitListConstraint(courses.Select(x => x.CourseName).ToArray()); + ////设置编辑的区域 + //dataValidation1 = sheet.GetDataValidationHelper().CreateValidation(dvConstraint1, new CellRangeAddressList(1, 65535, 3, 3)); + //sheet.AddValidationData(dataValidation1); + + dvConstraint1 = sheet.GetDataValidationHelper().CreateExplicitListConstraint(schools.Select(x => x.SchoolName).ToArray()); + //设置编辑的区域 + dataValidation1 = sheet.GetDataValidationHelper().CreateValidation(dvConstraint1, new CellRangeAddressList(1, 65535, 5, 5)); + sheet.AddValidationData(dataValidation1); + } //string sql = @"select 'Course' field, Id id, CourseNo no, CourseName name from Ghre_Course where IsEnable=1 and Status='Released'"; //var dataSourceLists = await Db.Ado.SqlQueryAsync(sql); //if (dataSourceLists.Any()) @@ -418,25 +465,23 @@ public class Ghre_PlanServices : BaseServices.OprateSuccess("计划暂存_" + DateTimeHelper.ConvertToSecondString1(DateTime.Now) + ".xlsx", physicsPath1); else