|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
using NPOI.SS.UserModel; |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
@ -372,4 +373,74 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<ServiceResult<string>> DownloadExcel(string menuName) |
|
|
|
|
{ |
|
|
|
|
var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot"; |
|
|
|
|
var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}ExcelTemplate{Path.DirectorySeparatorChar}"}"; |
|
|
|
|
if (!Directory.Exists(physicsPath + path)) |
|
|
|
|
Directory.CreateDirectory(physicsPath + path); |
|
|
|
|
|
|
|
|
|
Type entityType = typeof(Ghre_Course); |
|
|
|
|
var fileName = "F_TrainPlan.xlsx"; |
|
|
|
|
//physicsPath = physicsPath + path + fileName; |
|
|
|
|
|
|
|
|
|
IWorkbook hssfworkbook; |
|
|
|
|
ISheet sheet; |
|
|
|
|
using (FileStream file = new FileStream(physicsPath + path + fileName, FileMode.Open, FileAccess.Read)) |
|
|
|
|
{ |
|
|
|
|
//hssfworkbook = new HSSFWorkbook(file); |
|
|
|
|
//hssfworkbook = new XSSFWorkbook(file); |
|
|
|
|
hssfworkbook = WorkbookFactory.Create(file); |
|
|
|
|
} |
|
|
|
|
ISheet sheet2 = hssfworkbook.CreateSheet("下拉数据"); |
|
|
|
|
|
|
|
|
|
var newFileName = Guid.NewGuid() + ".xlsx"; |
|
|
|
|
int listColIndex = 0; |
|
|
|
|
//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<DataSourceList>(sql); |
|
|
|
|
//if (dataSourceLists.Any()) |
|
|
|
|
//{ |
|
|
|
|
// var types = new List<string> |
|
|
|
|
// { |
|
|
|
|
// "学习记录" |
|
|
|
|
// }; |
|
|
|
|
|
|
|
|
|
// types.ForEach(sheetName => |
|
|
|
|
// { |
|
|
|
|
// int sheetIndex = hssfworkbook.GetSheetIndex(sheetName); |
|
|
|
|
// if (sheetIndex >= 0) |
|
|
|
|
// { |
|
|
|
|
// sheet = hssfworkbook.GetSheetAt(sheetIndex); |
|
|
|
|
|
|
|
|
|
// SetCellDropdownList(sheet, 0, 0, dataSourceLists.Select(x => x.name).ToArray()); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// }); |
|
|
|
|
// MemoryStream ms; |
|
|
|
|
// using (ms = new MemoryStream()) |
|
|
|
|
// { |
|
|
|
|
// hssfworkbook.Write(ms); |
|
|
|
|
// ms.Flush(); |
|
|
|
|
// hssfworkbook.Dispose(); |
|
|
|
|
// //ms.Position = 0; |
|
|
|
|
// //return ms; |
|
|
|
|
// } |
|
|
|
|
// using (FileStream fs = new FileStream(physicsPath + path + newFileName, FileMode.Create, FileAccess.Write)) |
|
|
|
|
// { |
|
|
|
|
// byte[] data = ms.ToArray(); |
|
|
|
|
// fs.Write(data, 0, data.Length); |
|
|
|
|
// fs.Flush(); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
var physicsPath1 = physicsPath + path + fileName; |
|
|
|
|
if (menuName == "F_TrainPlan_Temporary") |
|
|
|
|
return ServiceResult<string>.OprateSuccess("计划暂存_" + DateTimeHelper.ConvertToSecondString1(DateTime.Now) + ".xlsx", physicsPath1); |
|
|
|
|
else |
|
|
|
|
return ServiceResult<string>.OprateSuccess("计划维护_" + DateTimeHelper.ConvertToSecondString1(DateTime.Now) + ".xlsx", physicsPath1); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |