|
|
@ -16,6 +16,7 @@ using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Tiobon.Core.Common; |
|
|
|
using Tiobon.Core.Common; |
|
|
|
using Tiobon.Core.Common.Extensions; |
|
|
|
using Tiobon.Core.Common.Extensions; |
|
|
|
|
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
using Tiobon.Core.Model.Models; |
|
|
|
using Tiobon.Core.Model.Models; |
|
|
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.DataAccess; |
|
|
|
namespace Tiobon.Core.DataAccess; |
|
|
@ -107,19 +108,24 @@ public static class ReportHelper |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static async Task<string> ImportTemplate(ISqlSugarClient Db, List<QueryExportColumn> tableColumn, DataTable dt, string menuName) |
|
|
|
public static string ImportTemplate(ISqlSugarClient Db, List<QueryExportColumn> tableColumn, DataTable dt, string menuName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
//生成表格 |
|
|
|
//生成表格 |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
tableColumn.Insert(0, new QueryExportColumn() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
field = "SerialNumber", |
|
|
|
|
|
|
|
label = "序号" |
|
|
|
|
|
|
|
}); |
|
|
|
//生成文件至文件服务器 |
|
|
|
//生成文件至文件服务器 |
|
|
|
var fid = SnowFlakeSingle.Instance.NextId(); |
|
|
|
var fid = SnowFlakeSingle.Instance.NextId(); |
|
|
|
var filepath = $"{$"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}import{Path.DirectorySeparatorChar}{fid}{Path.DirectorySeparatorChar}"}"; |
|
|
|
var filepath = $"{$"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}ExcelTemplate{Path.DirectorySeparatorChar}{menuName}{Path.DirectorySeparatorChar}"}"; |
|
|
|
if (!Directory.Exists(filepath)) |
|
|
|
if (!Directory.Exists(filepath)) |
|
|
|
Directory.CreateDirectory(filepath); |
|
|
|
Directory.CreateDirectory(filepath); |
|
|
|
var fname = $"{menuName}.xlsx"; |
|
|
|
|
|
|
|
|
|
|
|
var fname = $"{menuName}_{DateTimeHelper.ConvertToSecondString1(DateTime.Now)}.xlsx"; |
|
|
|
var sheetName = "导入数据"; |
|
|
|
var sheetName = "导入数据"; |
|
|
|
|
|
|
|
|
|
|
|
IWorkbook workbook = new XSSFWorkbook(); |
|
|
|
IWorkbook workbook = new XSSFWorkbook(); |
|
|
@ -243,17 +249,17 @@ public static class ReportHelper |
|
|
|
var dataSourceLists = GetDataSourceLists(Db, field, dataSource); |
|
|
|
var dataSourceLists = GetDataSourceLists(Db, field, dataSource); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fields = new List<string>() |
|
|
|
//var fields = new List<string>() |
|
|
|
{ |
|
|
|
//{ |
|
|
|
"InOrOut", |
|
|
|
// "InOrOut", |
|
|
|
"ResumeType", |
|
|
|
// "ResumeType", |
|
|
|
"ImportanceDegree", |
|
|
|
// "ImportanceDegree", |
|
|
|
"YearHumanId", |
|
|
|
// "YearHumanId", |
|
|
|
"TitleId" |
|
|
|
// "TitleId" |
|
|
|
}; |
|
|
|
//}; |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (dataSourceLists.Any() && fields.Contains(field)) |
|
|
|
if (dataSourceLists.Any()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//设置数据源的值 |
|
|
|
//设置数据源的值 |
|
|
|
IDataValidationConstraint dvConstraint1 = sheet.GetDataValidationHelper().CreateExplicitListConstraint(dataSourceLists.Where(x => x.name.IsNotEmptyOrNull()).Select(x => x.name).ToArray()); |
|
|
|
IDataValidationConstraint dvConstraint1 = sheet.GetDataValidationHelper().CreateExplicitListConstraint(dataSourceLists.Where(x => x.name.IsNotEmptyOrNull()).Select(x => x.name).ToArray()); |
|
|
@ -362,7 +368,7 @@ public static class ReportHelper |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
for (int rowNum = 2; rowNum <= sheet.LastRowNum; rowNum++) |
|
|
|
for (int rowNum = 1; rowNum <= sheet.LastRowNum; rowNum++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IRow currentRow = sheet.GetRow(rowNum); |
|
|
|
IRow currentRow = sheet.GetRow(rowNum); |
|
|
|
|
|
|
|
|
|
|
|