通用Excel导入处理

master
xiaochanghai 5 months ago
parent fa2508b790
commit 9b9d4f5690
  1. 2
      Tiobon.Core.Common/Attribute/QueryFilter.cs
  2. 11
      Tiobon.Core.DataAccess/ReportHelper.cs
  3. 30
      Tiobon.Core.Services/BASE/BaseServices.cs

@ -208,6 +208,8 @@ public class QueryExportColumn
public string dataSourceType { get; set; }
public int? dataSourceId { get; set; }
public string Comment { get; set; }
}
public class QueryExportReturn

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Http;
using NPOI.HSSF.UserModel;
using NPOI.OpenXmlFormats.Spreadsheet;
using NPOI.POIFS.NIO;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
@ -218,11 +219,16 @@ public static class ReportHelper
string dataSource = tableColumn[j].dataSource;
string field = tableColumn[j].field;
string label = tableColumn[j].label;
headerRow.CreateCell(j).SetCellValue(label);
var cel2 = headerRow.CreateCell(j);
cel2.SetCellValue(label);
if (tableColumn[j].required == "true")
headerRow.GetCell(j).CellStyle = headRequiredStyle;
else
headerRow.GetCell(j).CellStyle = headStyle;
if (tableColumn[j].Comment.IsNotEmptyOrNull())
cel2.CellComment = GetComment(sheet, null, j, tableColumn[j].Comment);
//设置列宽
//sheet.SetColumnWidth(column.Ordinal, (arrColWidth[column.Ordinal] + 1) * 256);
if (arrColWidth[j] > 255)
@ -234,6 +240,7 @@ public static class ReportHelper
sheet.SetColumnWidth(j, (arrColWidth[j] + 1) * 256);
}
//是否下拉
if (!string.IsNullOrEmpty(dataSource)
&& !dataSource.StartsWith("OrgTreeWith")
@ -828,7 +835,6 @@ public static class ReportHelper
/// <returns></returns>
public static async Task<(List<Dictionary<string, object>>, int)> ValidImportExcel(ISqlSugarClient Db, List<QueryExportColumn> columns, DataTable dt)
{
bool result = false;
int ErrorCount = 0;
var dictList = new List<Dictionary<string, object>>();
for (int i = 0; i < dt.Rows.Count; i++)
@ -929,7 +935,6 @@ public static class ReportHelper
{
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a));
ErrorCount++;
result = true;
continue;
}
else

@ -999,7 +999,35 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ
,
elementType
+ CASE WHEN multipleSelect = 'true' THEN '_multiple' ELSE '' END
elementType, APIDataSourceID dataSourceId --
elementType,
APIDataSourceID
dataSourceId,
CASE
WHEN elementType = 'YearMonthPicker' AND required = 'true'
THEN
';,(2024-01)'
WHEN elementType = 'YearMonthPicker'
THEN
',(2024-01)'
WHEN required = 'true'
THEN
''
WHEN required = 'true' AND dataType = 'int'
THEN
''
WHEN required = 'true' AND dataType = 'decimal'
THEN
''
WHEN required = 'false' AND dataType = 'int'
THEN
''
WHEN elementType = 'GDatePicker'
THEN
''
ELSE
NULL
END
Comment
FROM Ghrs_PageSettingEdit
WHERE IsEnable = 1
AND elementType NOT IN ('FnKey', 'PageGroup')

Loading…
Cancel
Save