ClosedXML 替代 npoi 修改
parent
7707b339dc
commit
8bf0be9699
|
|
@ -1,27 +1,15 @@
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
using ClosedXML.Excel;
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
using FellowOakDicom.Imaging.LUT;
|
|
||||||
using IRaCIS.Application.Contracts;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Application.Interfaces;
|
using IRaCIS.Application.Interfaces;
|
||||||
using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson;
|
|
||||||
using IRaCIS.Core.Application.Helper;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Migrations;
|
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using MiniExcelLibs;
|
using MiniExcelLibs;
|
||||||
using MiniExcelLibs.OpenXml;
|
using MiniExcelLibs.OpenXml;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NPOI.HSSF.UserModel;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using NPOI.SS.UserModel;
|
|
||||||
using NPOI.XSSF.UserModel;
|
|
||||||
using SharpCompress.Common;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Xceed.Document.NET;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service;
|
namespace IRaCIS.Core.Application.Service;
|
||||||
|
|
||||||
|
|
@ -155,19 +143,19 @@ public static class ExcelExportHelper
|
||||||
templateFile.CopyTo(templateStream);
|
templateFile.CopyTo(templateStream);
|
||||||
templateStream.Seek(0, SeekOrigin.Begin);
|
templateStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
var workbook = new XSSFWorkbook(templateStream);
|
using var workbook = new XLWorkbook(templateStream);
|
||||||
|
|
||||||
int sheetCount = workbook.NumberOfSheets;
|
int sheetCount = workbook.Worksheets.Count;
|
||||||
|
|
||||||
if (sheetCount == 2)
|
if (sheetCount == 2)
|
||||||
{
|
{
|
||||||
if (isEn_US)
|
if (isEn_US)
|
||||||
{
|
{
|
||||||
workbook.RemoveSheetAt(0);
|
workbook.Worksheets.Delete(1); // 删除第1个(索引1)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
workbook.RemoveSheetAt(1);
|
workbook.Worksheets.Delete(2); // 删除第2个(索引2)
|
||||||
}
|
}
|
||||||
|
|
||||||
//中文替换项目术语
|
//中文替换项目术语
|
||||||
|
|
@ -175,47 +163,36 @@ public static class ExcelExportHelper
|
||||||
{
|
{
|
||||||
var replaceObjectList = data.TrialObjectNameList;
|
var replaceObjectList = data.TrialObjectNameList;
|
||||||
|
|
||||||
var sheet = workbook.GetSheetAt(0);
|
// ClosedXML 获取第一个工作表
|
||||||
|
var worksheet = workbook.Worksheet(1); // 索引从1开始
|
||||||
|
|
||||||
int rowCount = sheet.PhysicalNumberOfRows;
|
// 获取使用的行范围(不包括空行)
|
||||||
|
var rowsUsed = worksheet.RowsUsed();
|
||||||
|
|
||||||
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
|
foreach (var row in rowsUsed)
|
||||||
{
|
{
|
||||||
var row = sheet.GetRow(rowIndex);
|
// 获取该行有数据的单元格
|
||||||
|
var cellsUsed = row.CellsUsed(c => c.DataType == XLDataType.Text);
|
||||||
|
|
||||||
if (row != null)
|
foreach (var cell in cellsUsed)
|
||||||
{
|
{
|
||||||
|
var cellValue = cell.GetString();
|
||||||
var colums = row.LastCellNum;
|
|
||||||
|
|
||||||
for (int colIndex = 0; colIndex < colums; colIndex++)
|
|
||||||
{
|
|
||||||
var cell = row.GetCell(colIndex);
|
|
||||||
|
|
||||||
// 只处理字符串类型的单元格
|
|
||||||
if (cell != null)
|
|
||||||
{
|
|
||||||
var cellValue = cell.StringCellValue;
|
|
||||||
|
|
||||||
var find = replaceObjectList.FirstOrDefault(t => t.Name == cellValue);
|
var find = replaceObjectList.FirstOrDefault(t => t.Name == cellValue);
|
||||||
if (find != null)
|
if (find != null)
|
||||||
{
|
{
|
||||||
cell.SetCellValue(find.TrialName);
|
cell.SetValue(find.TrialName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var memoryStream2 = new MemoryStream())
|
using (var memoryStream2 = new MemoryStream())
|
||||||
{
|
{
|
||||||
workbook.Write(memoryStream2, true);
|
workbook.SaveAs(memoryStream2);
|
||||||
|
|
||||||
memoryStream2.Seek(0, SeekOrigin.Begin);
|
memoryStream2.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
templateStream = memoryStream2;
|
templateStream = memoryStream2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -252,17 +229,17 @@ public static class ExcelExportHelper
|
||||||
public class DynamicColumnConfig
|
public class DynamicColumnConfig
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 增加动态列开始索引 从0 开始算
|
/// 增加动态列开始索引 npoi从0开始 现在ClosedXML 从1开始
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int AutoColumnStartIndex { get; set; }
|
public int AutoColumnStartIndex { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 动态列开始的行index 从0开始
|
/// 动态列开始的行index npoi从0开始 现在ClosedXML 从1开始
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int AutoColumnTitleRowIndex { get; set; }
|
public int AutoColumnTitleRowIndex { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模板列最后的索引
|
/// 模板列最后的索引 npoi从0开始 现在ClosedXML 从1开始
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TempalteLastColumnIndex { get; set; }
|
public int TempalteLastColumnIndex { get; set; }
|
||||||
|
|
||||||
|
|
@ -442,177 +419,174 @@ public static class ExcelExportHelper
|
||||||
templateFile.CopyTo(templateStream);
|
templateFile.CopyTo(templateStream);
|
||||||
templateStream.Seek(0, SeekOrigin.Begin);
|
templateStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
var workbook = new XSSFWorkbook(templateStream);
|
|
||||||
|
|
||||||
int sheetCount = workbook.NumberOfSheets;
|
using var workbook = new XLWorkbook(templateStream);
|
||||||
|
|
||||||
|
int sheetCount = workbook.Worksheets.Count;
|
||||||
|
|
||||||
if (sheetCount == 2)
|
if (sheetCount == 2)
|
||||||
{
|
{
|
||||||
if (isEn_US)
|
if (isEn_US)
|
||||||
{
|
{
|
||||||
workbook.RemoveSheetAt(0);
|
workbook.Worksheets.Delete(1); // 删除第1个(索引1)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
workbook.RemoveSheetAt(1);
|
workbook.Worksheets.Delete(2); // 删除第2个(索引2)
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 中文替换项目术语
|
#region 中文替换项目术语
|
||||||
|
//中文替换项目术语
|
||||||
if (data.TrialObjectNameList?.Count > 0)
|
if (data.TrialObjectNameList?.Count > 0)
|
||||||
{
|
{
|
||||||
var replaceObjectList = data.TrialObjectNameList;
|
var replaceObjectList = data.TrialObjectNameList;
|
||||||
|
|
||||||
var sheet = workbook.GetSheetAt(0);
|
// ClosedXML 获取第一个工作表
|
||||||
|
var worksheet = workbook.Worksheet(1); // 索引从1开始
|
||||||
|
|
||||||
int rowCount = sheet.PhysicalNumberOfRows;
|
// 获取使用的行范围(不包括空行)
|
||||||
|
var rowsUsed = worksheet.RowsUsed();
|
||||||
|
|
||||||
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
|
foreach (var row in rowsUsed)
|
||||||
{
|
{
|
||||||
var row = sheet.GetRow(rowIndex);
|
// 获取该行使用的列范围
|
||||||
if (row != null)
|
var cellsUsed = row.CellsUsed();
|
||||||
|
|
||||||
|
foreach (var cell in cellsUsed)
|
||||||
{
|
{
|
||||||
|
|
||||||
var colums = row.LastCellNum;
|
var cellValue = cell.GetString();
|
||||||
|
|
||||||
for (int colIndex = 0; colIndex < colums; colIndex++)
|
|
||||||
{
|
|
||||||
var cell = row.GetCell(colIndex);
|
|
||||||
|
|
||||||
// 只处理字符串类型的单元格
|
|
||||||
if (cell != null)
|
|
||||||
{
|
|
||||||
var cellValue = cell.StringCellValue;
|
|
||||||
|
|
||||||
var find = replaceObjectList.FirstOrDefault(t => t.Name == cellValue);
|
var find = replaceObjectList.FirstOrDefault(t => t.Name == cellValue);
|
||||||
if (find != null)
|
if (find != null)
|
||||||
{
|
{
|
||||||
cell.SetCellValue(find.TrialName);
|
cell.SetValue(find.TrialName);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
if (dynamicColumnConfig != null)
|
if (dynamicColumnConfig != null)
|
||||||
{
|
{
|
||||||
//var isCdics = dynamicColumnConfig.CDISCList.Count > 0;
|
|
||||||
|
|
||||||
var isCdics = dynamicColumnConfig.IsCDISCExport;
|
var isCdics = dynamicColumnConfig.IsCDISCExport;
|
||||||
|
|
||||||
var sheet = workbook.GetSheetAt(0);
|
// ClosedXML 获取工作表(索引从1开始)
|
||||||
|
var worksheet = workbook.Worksheet(1);
|
||||||
|
|
||||||
var cdicsRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex - 1);
|
// 获取行(ClosedXML 行索引从1开始,AutoColumnTitleRowIndex 已经改了保持不变)
|
||||||
var titelRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex);
|
var cdicsRow = worksheet.Row(dynamicColumnConfig.AutoColumnTitleRowIndex-1); // 原 NPOI: -1
|
||||||
var templateRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex + 1);
|
var titelRow = worksheet.Row(dynamicColumnConfig.AutoColumnTitleRowIndex); // 原 NPOI: 不变
|
||||||
|
var templateRow = worksheet.Row(dynamicColumnConfig.AutoColumnTitleRowIndex + 1); // 原 NPOI: +1
|
||||||
|
|
||||||
//动态移除列的数量
|
// 动态移除列的数量
|
||||||
var dynamicRemoveColunmCount = dynamicColumnConfig.RemoveColunmIndexList.Count();
|
var dynamicRemoveColunmCount = dynamicColumnConfig.RemoveColunmIndexList.Count();
|
||||||
|
|
||||||
//在动态列开始前移除的数量
|
// 在动态列开始前移除的数量
|
||||||
var beforeDynamicRemoveCount = dynamicColumnConfig.RemoveColunmIndexList.Where(t => t < dynamicColumnConfig.AutoColumnStartIndex).Count();
|
var beforeDynamicRemoveCount = dynamicColumnConfig.RemoveColunmIndexList.Count(t => t < dynamicColumnConfig.AutoColumnStartIndex);
|
||||||
|
|
||||||
//动态添加列的数量
|
// 动态添加列的数量
|
||||||
var needAddCount = dynamicColumnConfig.ColumnIdNameList.Count;
|
var needAddCount = dynamicColumnConfig.ColumnIdNameList.Count;
|
||||||
|
|
||||||
//原始表 最终索引
|
// 原始表最终索引(NPOI 从0开始,ClosedXML 从1开始,但这里存储的是逻辑索引,后续转换)
|
||||||
var originTotalEndIndex = dynamicColumnConfig.TempalteLastColumnIndex;
|
var originTotalEndIndex = dynamicColumnConfig.TempalteLastColumnIndex;
|
||||||
|
|
||||||
//减去动态移除后原始结束索引
|
// 减去动态移除后原始结束索引
|
||||||
var originRemoveEndIndex = originTotalEndIndex - dynamicRemoveColunmCount;
|
var originRemoveEndIndex = originTotalEndIndex - dynamicRemoveColunmCount;
|
||||||
|
|
||||||
//最终表 动态列开始索引
|
// 最终表动态列开始索引
|
||||||
var dynamicColunmStartIndex = dynamicColumnConfig.AutoColumnStartIndex - beforeDynamicRemoveCount;
|
var dynamicColunmStartIndex = dynamicColumnConfig.AutoColumnStartIndex - beforeDynamicRemoveCount;
|
||||||
|
|
||||||
//最终表 动态列的终止索引
|
// 最终表动态列的终止索引
|
||||||
var dynamicColunmEndIndex = dynamicColunmStartIndex + needAddCount - 1;
|
var dynamicColunmEndIndex = dynamicColunmStartIndex + needAddCount - 1;
|
||||||
|
|
||||||
//最终表 最终索引
|
// 最终表最终索引
|
||||||
var totalColunmEndIndex = originTotalEndIndex + needAddCount - dynamicRemoveColunmCount;
|
var totalColunmEndIndex = originTotalEndIndex + needAddCount - dynamicRemoveColunmCount;
|
||||||
|
|
||||||
|
// 删除需要动态删除的列 从大到小移除,否则索引会变
|
||||||
//动态列后需要移动的数量
|
// 动态列后需要移动的数量
|
||||||
var backMoveCount = totalColunmEndIndex - dynamicColunmEndIndex;
|
var backMoveCount = totalColunmEndIndex - dynamicColunmEndIndex;
|
||||||
|
|
||||||
//删除需要动态删除的列 从大到小移除,否则索引会变
|
// 删除需要动态删除的列(从大到小移除,否则索引会变)
|
||||||
|
// 注意:ClosedXML 可以直接使用 Delete() 方法,但为了保持原逻辑,这里使用手动移动
|
||||||
foreach (var removeIndex in dynamicColumnConfig.RemoveColunmIndexList.OrderByDescending(t => t))
|
foreach (var removeIndex in dynamicColumnConfig.RemoveColunmIndexList.OrderByDescending(t => t))
|
||||||
{
|
{
|
||||||
//将后面的列向前移动
|
// 将后面的列向前移动
|
||||||
for (var i = 0; i < originTotalEndIndex - removeIndex; i++)
|
for (var i = 0; i < originTotalEndIndex - removeIndex; i++)
|
||||||
{
|
{
|
||||||
Console.WriteLine(titelRow.GetCell(removeIndex + i + 1).StringCellValue);
|
|
||||||
titelRow.GetCell(removeIndex + i).SetCellValue(titelRow.GetCell(removeIndex + i + 1).StringCellValue);
|
|
||||||
templateRow.GetCell(removeIndex + i).SetCellValue(templateRow.GetCell(removeIndex + i + 1).StringCellValue);
|
|
||||||
|
|
||||||
//后面的数据要清空
|
int currentCol = removeIndex + i ;
|
||||||
titelRow.GetCell(removeIndex + i + 1).SetCellValue("");
|
int nextCol = removeIndex + i + 1;
|
||||||
templateRow.GetCell(removeIndex + i + 1).SetCellValue("");
|
|
||||||
|
|
||||||
|
Console.WriteLine(titelRow.Cell(nextCol).GetString());
|
||||||
|
|
||||||
|
// 移动值
|
||||||
|
titelRow.Cell(currentCol).SetValue(titelRow.Cell(nextCol).GetString());
|
||||||
|
templateRow.Cell(currentCol).SetValue(templateRow.Cell(nextCol).GetString());
|
||||||
|
|
||||||
|
// 清空后面的数据
|
||||||
|
titelRow.Cell(nextCol).SetValue(string.Empty);
|
||||||
|
templateRow.Cell(nextCol).SetValue(string.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// 创建新的列(ClosedXML 不需要显式创建,直接设置值即可)
|
||||||
|
|
||||||
//创建新的列
|
|
||||||
for (int i = originRemoveEndIndex; i < originRemoveEndIndex + needAddCount; i++)
|
for (int i = originRemoveEndIndex; i < originRemoveEndIndex + needAddCount; i++)
|
||||||
{
|
{
|
||||||
|
int colIndex = i + 1;
|
||||||
|
|
||||||
titelRow.CreateCell(i + 1);
|
// 不需要 CreateCell,直接设置值即可
|
||||||
templateRow.CreateCell(i + 1);
|
|
||||||
|
|
||||||
if (isCdics)
|
if (isCdics)
|
||||||
{
|
{
|
||||||
cdicsRow.CreateCell(i + 1);
|
cdicsRow.Cell(colIndex).SetValue(string.Empty);
|
||||||
}
|
}
|
||||||
|
titelRow.Cell(colIndex).SetValue(string.Empty);
|
||||||
|
templateRow.Cell(colIndex).SetValue(string.Empty);
|
||||||
}
|
}
|
||||||
//移动Title 和下面的模板标识
|
|
||||||
|
|
||||||
|
// 移动 Title 和下面的模板标识
|
||||||
var gap = totalColunmEndIndex - originRemoveEndIndex;
|
var gap = totalColunmEndIndex - originRemoveEndIndex;
|
||||||
|
|
||||||
for (int i = totalColunmEndIndex; i > dynamicColunmEndIndex; i--)
|
for (int i = totalColunmEndIndex; i > dynamicColunmEndIndex; i--)
|
||||||
{
|
{
|
||||||
|
int currentCol = i ;
|
||||||
|
int sourceCol = i - gap ;
|
||||||
|
|
||||||
titelRow.GetCell(i).SetCellValue(titelRow.GetCell(i - gap).StringCellValue);
|
titelRow.Cell(currentCol).SetValue(titelRow.Cell(sourceCol).GetString());
|
||||||
|
templateRow.Cell(currentCol).SetValue(templateRow.Cell(sourceCol).GetString());
|
||||||
templateRow.GetCell(i).SetCellValue(templateRow.GetCell(i - gap).StringCellValue);
|
|
||||||
|
|
||||||
if (isCdics)
|
if (isCdics)
|
||||||
{
|
{
|
||||||
cdicsRow.GetCell(i).SetCellValue(cdicsRow.GetCell(i - gap).StringCellValue);
|
cdicsRow.Cell(currentCol).SetValue(cdicsRow.Cell(sourceCol).GetString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置动态 Title
|
||||||
|
|
||||||
//设置动态Tilte
|
|
||||||
|
|
||||||
for (int i = dynamicColunmStartIndex; i < dynamicColunmStartIndex + needAddCount; i++)
|
for (int i = dynamicColunmStartIndex; i < dynamicColunmStartIndex + needAddCount; i++)
|
||||||
{
|
{
|
||||||
|
int colIndex = i ;
|
||||||
|
var index = i - dynamicColunmStartIndex;
|
||||||
|
var name = dynamicColumnConfig.ColumnIdNameList[index].Name;
|
||||||
|
|
||||||
var name = dynamicColumnConfig.ColumnIdNameList[i - dynamicColunmStartIndex].Name;
|
titelRow.Cell(colIndex).SetValue(name);
|
||||||
|
templateRow.Cell(colIndex).SetValue(string.Empty);
|
||||||
titelRow.GetCell(i).SetCellValue(name);
|
|
||||||
templateRow.GetCell(i).SetCellValue("");
|
|
||||||
|
|
||||||
if (isCdics)
|
if (isCdics)
|
||||||
{
|
{
|
||||||
var cdicsCode = dynamicColumnConfig.ColumnIdNameList[i - dynamicColunmStartIndex].CDISCCode;
|
var cdicsCode = dynamicColumnConfig.ColumnIdNameList[index].CDISCCode;
|
||||||
|
cdicsRow.Cell(colIndex).SetValue(cdicsCode);
|
||||||
cdicsRow.GetCell(i).SetCellValue(cdicsCode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
using (var memoryStream2 = new MemoryStream())
|
using (var memoryStream2 = new MemoryStream())
|
||||||
{
|
{
|
||||||
workbook.Write(memoryStream2, true);
|
workbook.SaveAs(memoryStream2);
|
||||||
|
|
||||||
memoryStream2.Seek(0, SeekOrigin.Begin);
|
memoryStream2.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
templateStream = memoryStream2;
|
templateStream = memoryStream2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -643,9 +617,9 @@ public static class ExcelExportHelper
|
||||||
|
|
||||||
var dynamicTranslateDataList = await _dictionaryService.GetBasicDataSelect(dynamicColumnConfig.TranslateDicNameList.ToArray());
|
var dynamicTranslateDataList = await _dictionaryService.GetBasicDataSelect(dynamicColumnConfig.TranslateDicNameList.ToArray());
|
||||||
|
|
||||||
// 使用NPOI 进行二次处理
|
// 使用 ClosedXML 进行二次处理
|
||||||
var wb = new XSSFWorkbook(memoryStream);
|
using var wb = new XLWorkbook(memoryStream);
|
||||||
var sheet = wb.GetSheetAt(0);
|
var worksheet = wb.Worksheet(1); // 获取第一个工作表,索引从1开始
|
||||||
|
|
||||||
var list = translatedDic["List"] as IList;
|
var list = translatedDic["List"] as IList;
|
||||||
|
|
||||||
|
|
@ -653,8 +627,8 @@ public static class ExcelExportHelper
|
||||||
{
|
{
|
||||||
var index = list.IndexOf(itemResult);
|
var index = list.IndexOf(itemResult);
|
||||||
|
|
||||||
//从第四行开始处理动态列
|
// 从第四行开始处理动态列
|
||||||
var row = sheet.GetRow(index + dynamicColumnConfig.AutoColumnTitleRowIndex + 1);
|
var row = worksheet.Row(index + dynamicColumnConfig.AutoColumnTitleRowIndex + 1); // +2 因为 NPOI 从0,ClosedXML 从1
|
||||||
|
|
||||||
var itemDic = itemResult.ToDictionary();
|
var itemDic = itemResult.ToDictionary();
|
||||||
|
|
||||||
|
|
@ -675,11 +649,11 @@ public static class ExcelExportHelper
|
||||||
|
|
||||||
if (isExcelAddDataWithName)
|
if (isExcelAddDataWithName)
|
||||||
{
|
{
|
||||||
writeIndex = dynamicColumnConfig.ColumnNameList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleName].ToString()) + dynamicColumnConfig.AutoColumnStartIndex;
|
writeIndex = dynamicColumnConfig.ColumnNameList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleName].ToString()) + dynamicColumnConfig.AutoColumnStartIndex ; // +1 因为 ClosedXML 列从1开始
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
writeIndex = dynamicColumnConfig.ColumnIdList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleId].ToString()) + dynamicColumnConfig.AutoColumnStartIndex;
|
writeIndex = dynamicColumnConfig.ColumnIdList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleId].ToString()) + dynamicColumnConfig.AutoColumnStartIndex ; // +1 因为 ClosedXML 列从1开始
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -723,7 +697,8 @@ public static class ExcelExportHelper
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
row.GetCell(writeIndex).SetCellValue(translatedItemData);
|
// ClosedXML 设置单元格值
|
||||||
|
row.Cell(writeIndex).SetValue(translatedItemData);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -732,13 +707,11 @@ public static class ExcelExportHelper
|
||||||
|
|
||||||
if (unit.IsNotNullOrEmpty() && unit == "9")
|
if (unit.IsNotNullOrEmpty() && unit == "9")
|
||||||
{
|
{
|
||||||
row.GetCell(writeIndex).SetCellValue(itemValue + "%");
|
row.Cell(writeIndex).SetValue(itemValue + "%");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
row.GetCell(writeIndex).SetCellValue(itemValue);
|
row.Cell(writeIndex).SetValue(itemValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -748,7 +721,7 @@ public static class ExcelExportHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
var memoryStream2 = new MemoryStream();
|
var memoryStream2 = new MemoryStream();
|
||||||
wb.Write(memoryStream2, true);
|
wb.SaveAs(memoryStream2, true);
|
||||||
memoryStream2.Seek(0, SeekOrigin.Begin);
|
memoryStream2.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
memoryStream = memoryStream2;
|
memoryStream = memoryStream2;
|
||||||
|
|
@ -764,323 +737,6 @@ public static class ExcelExportHelper
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 暂时废弃--合并到上面
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="code"></param>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
/// <param name="_commonDocumentRepository"></param>
|
|
||||||
/// <param name="_hostEnvironment"></param>
|
|
||||||
/// <param name="_dictionaryService"></param>
|
|
||||||
/// <param name="translateType"></param>
|
|
||||||
/// <param name="criterionType"></param>
|
|
||||||
/// <param name="dynamicColumnConfig"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static async Task<(MemoryStream, string)> CDISC_DataExport_Async(string code, ExcelExportInfo data, IRepository<CommonDocument> _commonDocumentRepository, IWebHostEnvironment _hostEnvironment, IDictionaryService? _dictionaryService = null, Type? translateType = null, CriterionType? criterionType = null, DynamicColumnConfig? dynamicColumnConfig = null)
|
|
||||||
{
|
|
||||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
|
||||||
//判断是否有字典翻译
|
|
||||||
|
|
||||||
object translateData = data;
|
|
||||||
|
|
||||||
Dictionary<string, object> translatedDic = default;
|
|
||||||
|
|
||||||
if (_dictionaryService != null && translateType != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
//一个值 对应不同的字典翻译
|
|
||||||
var needTranslatePropertyList = translateType.GetProperties().Where(t => t.IsDefined(typeof(DictionaryTranslateAttribute), true))
|
|
||||||
.SelectMany(c =>
|
|
||||||
c.GetCustomAttributes(typeof(DictionaryTranslateAttribute), false).Select(f => (DictionaryTranslateAttribute?)f).Where(t => t.CriterionType == criterionType || t.CriterionType == null)
|
|
||||||
.Select(k => new { c.Name, k.DicParentCode, k.IsTranslateDenpendOtherProperty, k.DependPropertyName, k.DependPropertyValueStr })
|
|
||||||
).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//字典表查询出所有需要翻译的数据
|
|
||||||
|
|
||||||
var translateDataList = await _dictionaryService.GetBasicDataSelect(needTranslatePropertyList.Select(t => t.DicParentCode).Distinct().ToArray());
|
|
||||||
|
|
||||||
var dic = data.ConvertToDictionary();
|
|
||||||
//var dic = (JsonConvert.DeserializeObject<IDictionary<string, object>>(data.ToJsonNotIgnoreNull())).IfNullThrowException();
|
|
||||||
|
|
||||||
foreach (var key in dic.Keys)
|
|
||||||
{
|
|
||||||
//是数组 那么找到对应的属性 进行翻译
|
|
||||||
if (dic[key] != null && dic[key].GetType().GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList<>)))
|
|
||||||
//if (dic[key].GetType().IsAssignableFrom(typeof(JArray)))
|
|
||||||
{
|
|
||||||
|
|
||||||
var newObjList = new List<object>();
|
|
||||||
var no = 1;
|
|
||||||
foreach (var item in dic[key] as IList)
|
|
||||||
//foreach (var item in dic[key] as JArray)
|
|
||||||
{
|
|
||||||
//var itemDic = JsonConvert.DeserializeObject<IDictionary<string, object>>(item.ToJsonNotIgnoreNull());
|
|
||||||
var itemDic = item.ConvertToDictionary();
|
|
||||||
|
|
||||||
foreach (var needTranslateProperty in needTranslatePropertyList)
|
|
||||||
{
|
|
||||||
if (itemDic.Keys.Any(t => t == needTranslateProperty.Name))
|
|
||||||
{
|
|
||||||
//翻译的属性依赖其他属性
|
|
||||||
if (needTranslateProperty.IsTranslateDenpendOtherProperty)
|
|
||||||
{
|
|
||||||
if (itemDic[needTranslateProperty.DependPropertyName]?.ToString().ToLower() == needTranslateProperty.DependPropertyValueStr.ToLower())
|
|
||||||
{
|
|
||||||
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
|
||||||
|
|
||||||
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//普通翻译 或者某一标准翻译
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var beforeValue = itemDic[needTranslateProperty.Name]?.ToString();
|
|
||||||
|
|
||||||
|
|
||||||
itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
itemDic.Add("No", no++);
|
|
||||||
newObjList.Add(itemDic);
|
|
||||||
}
|
|
||||||
|
|
||||||
dic[key] = newObjList;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//data = dic;
|
|
||||||
translateData = dic;
|
|
||||||
translatedDic = dic;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var (physicalPath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code);
|
|
||||||
|
|
||||||
|
|
||||||
//模板路径
|
|
||||||
var tplPath = physicalPath;
|
|
||||||
|
|
||||||
|
|
||||||
// 获取文件流
|
|
||||||
var templateStream = new MemoryStream();
|
|
||||||
|
|
||||||
#region 根据中英文 删除模板sheet
|
|
||||||
|
|
||||||
// 打开模板文件
|
|
||||||
var templateFileStream = new FileStream(tplPath, FileMode.Open, FileAccess.Read);
|
|
||||||
|
|
||||||
var workbook = new XSSFWorkbook(templateFileStream);
|
|
||||||
|
|
||||||
int sheetCount = workbook.NumberOfSheets;
|
|
||||||
|
|
||||||
if (sheetCount == 2)
|
|
||||||
{
|
|
||||||
if (isEn_US)
|
|
||||||
{
|
|
||||||
workbook.RemoveSheetAt(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
workbook.RemoveSheetAt(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dynamicColumnConfig != null)
|
|
||||||
{
|
|
||||||
var sheet = workbook.GetSheetAt(0);
|
|
||||||
|
|
||||||
|
|
||||||
var cdicsRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex - 1);
|
|
||||||
var titelRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex);
|
|
||||||
var templateRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex + 1);
|
|
||||||
|
|
||||||
//动态移除列的数量
|
|
||||||
var dynamicRemoveColunmCount = dynamicColumnConfig.RemoveColunmIndexList.Count();
|
|
||||||
|
|
||||||
//在动态列开始前移除的数量
|
|
||||||
var beforeDynamicRemoveCount = dynamicColumnConfig.RemoveColunmIndexList.Where(t => t < dynamicColumnConfig.AutoColumnStartIndex).Count();
|
|
||||||
|
|
||||||
//动态添加列的数量
|
|
||||||
var needAddCount = dynamicColumnConfig.ColumnIdNameList.Count;
|
|
||||||
|
|
||||||
//原始表 最终索引
|
|
||||||
var originTotalEndIndex = dynamicColumnConfig.TempalteLastColumnIndex;
|
|
||||||
|
|
||||||
//减去动态移除后原始结束索引
|
|
||||||
var originRemoveEndIndex = originTotalEndIndex - dynamicRemoveColunmCount;
|
|
||||||
|
|
||||||
//最终表 动态列开始索引
|
|
||||||
var dynamicColunmStartIndex = dynamicColumnConfig.AutoColumnStartIndex - beforeDynamicRemoveCount;
|
|
||||||
|
|
||||||
//最终表 动态列的终止索引
|
|
||||||
var dynamicColunmEndIndex = dynamicColunmStartIndex + needAddCount - 1;
|
|
||||||
|
|
||||||
//最终表 最终索引
|
|
||||||
var totalColunmEndIndex = originTotalEndIndex + needAddCount - dynamicRemoveColunmCount;
|
|
||||||
|
|
||||||
|
|
||||||
//动态列后需要移动的数量
|
|
||||||
var backMoveCount = totalColunmEndIndex - dynamicColunmEndIndex;
|
|
||||||
|
|
||||||
//删除需要动态删除的列 从大到小移除,否则索引会变
|
|
||||||
foreach (var removeIndex in dynamicColumnConfig.RemoveColunmIndexList.OrderByDescending(t => t))
|
|
||||||
{
|
|
||||||
//将后面的列向前移动
|
|
||||||
for (var i = 0; i < originTotalEndIndex - removeIndex; i++)
|
|
||||||
{
|
|
||||||
Console.WriteLine(titelRow.GetCell(removeIndex + i + 1).StringCellValue);
|
|
||||||
titelRow.GetCell(removeIndex + i).SetCellValue(titelRow.GetCell(removeIndex + i + 1).StringCellValue);
|
|
||||||
templateRow.GetCell(removeIndex + i).SetCellValue(templateRow.GetCell(removeIndex + i + 1).StringCellValue);
|
|
||||||
|
|
||||||
//后面的数据要清空
|
|
||||||
titelRow.GetCell(removeIndex + i + 1).SetCellValue("");
|
|
||||||
templateRow.GetCell(removeIndex + i + 1).SetCellValue("");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//创建新的列
|
|
||||||
for (int i = originTotalEndIndex; i < originTotalEndIndex + needAddCount; i++)
|
|
||||||
{
|
|
||||||
cdicsRow.CreateCell(i + 1);
|
|
||||||
titelRow.CreateCell(i + 1);
|
|
||||||
templateRow.CreateCell(i + 1);
|
|
||||||
}
|
|
||||||
//移动Title 和下面的模板标识
|
|
||||||
|
|
||||||
var gap = totalColunmEndIndex - originRemoveEndIndex;
|
|
||||||
|
|
||||||
for (int i = totalColunmEndIndex; i > dynamicColunmEndIndex; i--)
|
|
||||||
{
|
|
||||||
|
|
||||||
titelRow.GetCell(i).SetCellValue(titelRow.GetCell(i - gap).StringCellValue);
|
|
||||||
|
|
||||||
templateRow.GetCell(i).SetCellValue(templateRow.GetCell(i - gap).StringCellValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//设置动态Tilte
|
|
||||||
|
|
||||||
for (int i = dynamicColunmStartIndex; i < dynamicColunmStartIndex + needAddCount; i++)
|
|
||||||
{
|
|
||||||
var name = dynamicColumnConfig.ColumnIdNameList[i - dynamicColunmStartIndex].Name;
|
|
||||||
|
|
||||||
var cdicsCode = dynamicColumnConfig.ColumnIdNameList[i - dynamicColunmStartIndex].CDISCCode;
|
|
||||||
|
|
||||||
cdicsRow.GetCell(i).SetCellValue(cdicsCode);
|
|
||||||
titelRow.GetCell(i).SetCellValue(name);
|
|
||||||
templateRow.GetCell(i).SetCellValue("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
workbook.Write(templateStream, leaveOpen: true);
|
|
||||||
templateStream.Position = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region MiniExcel
|
|
||||||
|
|
||||||
var memoryStream = new MemoryStream();
|
|
||||||
|
|
||||||
var config = new OpenXmlConfiguration()
|
|
||||||
{
|
|
||||||
IgnoreTemplateParameterMissing = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
await MiniExcel.SaveAsByTemplateAsync(memoryStream, templateStream.ToArray(), translateData, config);
|
|
||||||
|
|
||||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
if (dynamicColumnConfig != null)
|
|
||||||
{
|
|
||||||
var isExcelAddDataWithName = dynamicColumnConfig.ColumnIdNameList.Select(t => t.Id).Count() == 1;
|
|
||||||
|
|
||||||
var dynamicTranslateDataList = await _dictionaryService.GetBasicDataSelect(dynamicColumnConfig.TranslateDicNameList.ToArray());
|
|
||||||
|
|
||||||
// 使用NPOI 进行二次处理
|
|
||||||
var wb = new XSSFWorkbook(memoryStream);
|
|
||||||
var sheet = wb.GetSheetAt(0);
|
|
||||||
|
|
||||||
var list = translatedDic["List"] as IList;
|
|
||||||
|
|
||||||
foreach (var itemResult in list)
|
|
||||||
{
|
|
||||||
var index = list.IndexOf(itemResult);
|
|
||||||
|
|
||||||
//从第四行开始处理动态列
|
|
||||||
var row = sheet.GetRow(index + dynamicColumnConfig.AutoColumnTitleRowIndex + 1);
|
|
||||||
|
|
||||||
var itemDic = itemResult.ToDictionary();
|
|
||||||
|
|
||||||
var itemList = itemDic[dynamicColumnConfig.DynamicListName] as IList;
|
|
||||||
|
|
||||||
//这个数组是动态的,有的多,有的少,所以在此对比Title 一致才赋值
|
|
||||||
foreach (var itemObj in itemList)
|
|
||||||
{
|
|
||||||
|
|
||||||
var iteObjDic = itemObj.ToDictionary();
|
|
||||||
|
|
||||||
var itemDicName = iteObjDic[dynamicColumnConfig.DynamicItemDicName]?.ToString();
|
|
||||||
var itemValue = iteObjDic[dynamicColumnConfig.DynamicItemValueName]?.ToString();
|
|
||||||
|
|
||||||
//var writeIndex = itemList.IndexOf(itemObj) + dynamicColumnConfig.AutoColumnStartIndex;
|
|
||||||
|
|
||||||
var writeIndex = 0;
|
|
||||||
if (isExcelAddDataWithName)
|
|
||||||
{
|
|
||||||
writeIndex = dynamicColumnConfig.ColumnNameList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleName].ToString()) + dynamicColumnConfig.AutoColumnStartIndex;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writeIndex = dynamicColumnConfig.ColumnIdList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleId].ToString()) + dynamicColumnConfig.AutoColumnStartIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemDicName.IsNotNullOrEmpty())
|
|
||||||
{
|
|
||||||
|
|
||||||
var translatedItemData = dynamicTranslateDataList[itemDicName].Where(t => t.Code.ToLower() == itemValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
|
|
||||||
|
|
||||||
row.GetCell(writeIndex).SetCellValue(translatedItemData);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
row.GetCell(writeIndex).SetCellValue(itemValue);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var memoryStream2 = new MemoryStream();
|
|
||||||
wb.Write(memoryStream2, true);
|
|
||||||
memoryStream2.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
memoryStream = memoryStream2;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return (memoryStream, fileName);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1104,38 +760,28 @@ public static class ExcelExportHelper
|
||||||
// 打开模板文件
|
// 打开模板文件
|
||||||
using var templateFileStream = new FileStream(tplPath, FileMode.Open, FileAccess.Read);
|
using var templateFileStream = new FileStream(tplPath, FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
using var workbook = new XSSFWorkbook(templateFileStream);
|
using var workbook = new XLWorkbook(templateFileStream);
|
||||||
|
|
||||||
int sheetCount = workbook.NumberOfSheets;
|
int sheetCount = workbook.Worksheets.Count;
|
||||||
|
|
||||||
int removeRowIndex = 1; // 要删除的行(0-based)
|
int removeRowIndex = 2; // ClosedXML 中行索引从 1 开始,所以第2行对应 NPOI 的第1行
|
||||||
|
|
||||||
for (int i = 0; i < sheetCount; i++)
|
for (int i = 1; i <= sheetCount; i++) // ClosedXML 工作表索引从 1 开始
|
||||||
{
|
{
|
||||||
var sheet = workbook.GetSheetAt(i);
|
var worksheet = workbook.Worksheet(i);
|
||||||
|
|
||||||
// 2️ 删除行
|
// 删除行
|
||||||
var row = sheet.GetRow(removeRowIndex);
|
var row = worksheet.Row(removeRowIndex);
|
||||||
if (row != null)
|
if (!row.IsEmpty() || row.CellsUsed().Any()) // 检查行是否存在数据
|
||||||
{
|
{
|
||||||
sheet.RemoveRow(row);
|
row.Delete(); // ClosedXML 直接删除行
|
||||||
}
|
|
||||||
|
|
||||||
// 3️ 上移后续行
|
|
||||||
if (removeRowIndex < sheet.LastRowNum)
|
|
||||||
{
|
|
||||||
sheet.ShiftRows(
|
|
||||||
removeRowIndex + 1,
|
|
||||||
sheet.LastRowNum,
|
|
||||||
-1,
|
|
||||||
true, // copyRowHeight
|
|
||||||
false // resetOriginalRowHeight
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
workbook.Write(templateStream, leaveOpen: true);
|
workbook.SaveAs(templateStream);
|
||||||
templateStream.Position = 0;
|
templateStream.Position = 0;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1182,72 +828,64 @@ public static class ExcelExportHelper
|
||||||
//模板路径
|
//模板路径
|
||||||
var tplPath = physicalPath;
|
var tplPath = physicalPath;
|
||||||
|
|
||||||
#region 根据中英文 删除模板sheet
|
#region 根据中英文删除模板 sheet(使用 ClosedXML)
|
||||||
|
|
||||||
// 打开模板文件
|
using var templateFileStream = new FileStream(tplPath, FileMode.Open, FileAccess.Read);
|
||||||
var templateFile = new FileStream(tplPath, FileMode.Open, FileAccess.Read);
|
using var workbook = new XLWorkbook(templateFileStream);
|
||||||
|
|
||||||
// 获取文件流
|
int sheetCount = workbook.Worksheets.Count;
|
||||||
var templateStream = new MemoryStream();
|
|
||||||
templateFile.CopyTo(templateStream);
|
|
||||||
templateStream.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
var workbook = new XSSFWorkbook(templateStream);
|
|
||||||
|
|
||||||
int sheetCount = workbook.NumberOfSheets;
|
|
||||||
|
|
||||||
if (sheetCount == 2)
|
if (sheetCount == 2)
|
||||||
{
|
{
|
||||||
if (inDto.IsEnglish)
|
if (inDto.IsEnglish)
|
||||||
{
|
{
|
||||||
workbook.RemoveSheetAt(0);
|
workbook.Worksheet(1).Delete(); // 删除第一个工作表
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
workbook.RemoveSheetAt(1);
|
workbook.Worksheet(2).Delete(); // 删除第二个工作表
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
// 获取第一个工作表(删除后剩下的那个)
|
||||||
|
var worksheet = workbook.Worksheet(1);
|
||||||
|
|
||||||
ISheet sheet = workbook.GetSheetAt(0); // 获取第一个工作表
|
// 遍历所有行和列,替换模板占位符
|
||||||
|
var rowsUsed = worksheet.RowsUsed();
|
||||||
|
|
||||||
|
foreach (var row in rowsUsed)
|
||||||
|
|
||||||
for (int i = 0; i < sheet.LastRowNum + 1; i++)
|
|
||||||
{
|
{
|
||||||
IRow row = sheet.GetRow(i);
|
var cellsUsed = row.CellsUsed(c => c.DataType == XLDataType.Text);
|
||||||
for (int j = 0; j < sheet.LastRowNum; j++)
|
|
||||||
|
foreach (var cell in cellsUsed)
|
||||||
{
|
{
|
||||||
ICell cell = row.GetCell(j);
|
var cellValue = cell.GetString();
|
||||||
|
|
||||||
|
// 检查是否包含模板占位符 {{PropertyName}}
|
||||||
foreach (var property in inDto.Data.GetType().GetProperties())
|
foreach (var property in inDto.Data.GetType().GetProperties())
|
||||||
{
|
{
|
||||||
var value = property.GetValue(inDto.Data);
|
var placeholder = "{{" + property.Name + "}}";
|
||||||
if (cell != null && cell.ToString() == "{{" + property.Name + "}}")
|
if (cellValue.Contains(placeholder))
|
||||||
{
|
{
|
||||||
sheet.GetRow(i).GetCell(j).SetCellValue(value.ToString());
|
var value = property.GetValue(inDto.Data);
|
||||||
|
var newValue = cellValue.Replace(placeholder, value?.ToString() ?? string.Empty);
|
||||||
|
cell.SetValue(newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
workbook.SaveAs(memoryStream);
|
||||||
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||||
var memoryStream2 = new MemoryStream();
|
|
||||||
workbook.Write(memoryStream2, true);
|
|
||||||
|
|
||||||
memoryStream2.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
templateStream = memoryStream2;
|
|
||||||
|
|
||||||
|
|
||||||
return new FileStreamResult(templateStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
||||||
{
|
{
|
||||||
FileDownloadName = $"{(string.IsNullOrEmpty(inDto.ExportFileName) ? "" : inDto.ExportFileName + "_")}{Path.GetFileNameWithoutExtension(fileName)}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"
|
FileDownloadName = $"{(string.IsNullOrEmpty(inDto.ExportFileName) ? "" : inDto.ExportFileName + "_")}{Path.GetFileNameWithoutExtension(fileName)}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using IRaCIS.Core.Domain.Share;
|
using System.Globalization;
|
||||||
using NPOI.XWPF.UserModel;
|
|
||||||
using System.Globalization;
|
|
||||||
using Xceed.Document.NET;
|
using Xceed.Document.NET;
|
||||||
using Xceed.Words.NET;
|
using Xceed.Words.NET;
|
||||||
|
|
||||||
|
|
@ -54,42 +52,42 @@ public static class WordTempleteHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void Npoi_GetInternationalTempleteStream(string filePath, Stream memoryStream)
|
//public static void Npoi_GetInternationalTempleteStream(string filePath, Stream memoryStream)
|
||||||
{
|
//{
|
||||||
|
|
||||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
// var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||||
|
|
||||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
// using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||||
{
|
// {
|
||||||
XWPFDocument doc = new XWPFDocument(fs);
|
// XWPFDocument doc = new XWPFDocument(fs);
|
||||||
|
|
||||||
// 查找包含指定书签的段落及其索引
|
// // 查找包含指定书签的段落及其索引
|
||||||
var bookmarkParagraph = doc.Paragraphs
|
// var bookmarkParagraph = doc.Paragraphs
|
||||||
.FirstOrDefault(p => p.GetCTP().GetBookmarkStartList().Any(b => b.name == StaticData.CultureInfo.en_US_bookMark));
|
// .FirstOrDefault(p => p.GetCTP().GetBookmarkStartList().Any(b => b.name == StaticData.CultureInfo.en_US_bookMark));
|
||||||
|
|
||||||
if (bookmarkParagraph != null)
|
// if (bookmarkParagraph != null)
|
||||||
{
|
// {
|
||||||
int bookmarkIndex = doc.Paragraphs.IndexOf(bookmarkParagraph);
|
// int bookmarkIndex = doc.Paragraphs.IndexOf(bookmarkParagraph);
|
||||||
|
|
||||||
if (isEn_US)
|
// if (isEn_US)
|
||||||
{
|
// {
|
||||||
// 从书签所在段落开始,删除之前的所有段落
|
// // 从书签所在段落开始,删除之前的所有段落
|
||||||
for (int i = bookmarkIndex - 1; i >= 0; i--)
|
// for (int i = bookmarkIndex - 1; i >= 0; i--)
|
||||||
{
|
// {
|
||||||
doc.RemoveBodyElement(i);
|
// doc.RemoveBodyElement(i);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
// 删除书签之后的所有段落
|
// // 删除书签之后的所有段落
|
||||||
for (int i = doc.Paragraphs.Count - 1; i >= bookmarkIndex; i--)
|
// for (int i = doc.Paragraphs.Count - 1; i >= bookmarkIndex; i--)
|
||||||
{
|
// {
|
||||||
doc.RemoveBodyElement(i);
|
// doc.RemoveBodyElement(i);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
doc.Write(memoryStream);
|
// doc.Write(memoryStream);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,5 @@
|
||||||
using System;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Security;
|
|
||||||
using System.Net;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Helper.OtherTool
|
namespace IRaCIS.Core.Application.Helper.OtherTool
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="ClosedXML" Version="0.105.0" />
|
||||||
<PackageReference Include="IdentityModel.OidcClient" Version="6.0.0" />
|
<PackageReference Include="IdentityModel.OidcClient" Version="6.0.0" />
|
||||||
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.2.0" />
|
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.2.0" />
|
||||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
|
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
|
||||||
|
|
@ -57,7 +58,6 @@
|
||||||
<PackageReference Include="My.Extensions.Localization.Json" Version="4.0.0">
|
<PackageReference Include="My.Extensions.Localization.Json" Version="4.0.0">
|
||||||
<TreatAsUsed>true</TreatAsUsed>
|
<TreatAsUsed>true</TreatAsUsed>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="NPOI" Version="2.7.4" />
|
|
||||||
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.2" />
|
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.2" />
|
||||||
<PackageReference Include="RestSharp" Version="114.0.0" />
|
<PackageReference Include="RestSharp" Version="114.0.0" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
|
||||||
|
|
|
||||||
|
|
@ -59,17 +59,17 @@
|
||||||
</member>
|
</member>
|
||||||
<member name="P:IRaCIS.Core.Application.Service.ExcelExportHelper.DynamicColumnConfig.AutoColumnStartIndex">
|
<member name="P:IRaCIS.Core.Application.Service.ExcelExportHelper.DynamicColumnConfig.AutoColumnStartIndex">
|
||||||
<summary>
|
<summary>
|
||||||
增加动态列开始索引 从0 开始算
|
增加动态列开始索引 npoi从0开始 现在ClosedXML 从1开始
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:IRaCIS.Core.Application.Service.ExcelExportHelper.DynamicColumnConfig.AutoColumnTitleRowIndex">
|
<member name="P:IRaCIS.Core.Application.Service.ExcelExportHelper.DynamicColumnConfig.AutoColumnTitleRowIndex">
|
||||||
<summary>
|
<summary>
|
||||||
动态列开始的行index 从0开始
|
动态列开始的行index npoi从0开始 现在ClosedXML 从1开始
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:IRaCIS.Core.Application.Service.ExcelExportHelper.DynamicColumnConfig.TempalteLastColumnIndex">
|
<member name="P:IRaCIS.Core.Application.Service.ExcelExportHelper.DynamicColumnConfig.TempalteLastColumnIndex">
|
||||||
<summary>
|
<summary>
|
||||||
模板列最后的索引
|
模板列最后的索引 npoi从0开始 现在ClosedXML 从1开始
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:IRaCIS.Core.Application.Service.ExcelExportHelper.DynamicColumnConfig.ColumnIdNameList">
|
<member name="P:IRaCIS.Core.Application.Service.ExcelExportHelper.DynamicColumnConfig.ColumnIdNameList">
|
||||||
|
|
@ -102,20 +102,6 @@
|
||||||
Excel Title Name
|
Excel Title Name
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:IRaCIS.Core.Application.Service.ExcelExportHelper.CDISC_DataExport_Async(System.String,IRaCIS.Application.Contracts.ExcelExportInfo,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.CommonDocument},Microsoft.AspNetCore.Hosting.IWebHostEnvironment,IRaCIS.Application.Interfaces.IDictionaryService,System.Type,System.Nullable{IRaCIS.Core.Domain.Share.CriterionType},IRaCIS.Core.Application.Service.ExcelExportHelper.DynamicColumnConfig)">
|
|
||||||
<summary>
|
|
||||||
暂时废弃--合并到上面
|
|
||||||
</summary>
|
|
||||||
<param name="code"></param>
|
|
||||||
<param name="data"></param>
|
|
||||||
<param name="_commonDocumentRepository"></param>
|
|
||||||
<param name="_hostEnvironment"></param>
|
|
||||||
<param name="_dictionaryService"></param>
|
|
||||||
<param name="translateType"></param>
|
|
||||||
<param name="criterionType"></param>
|
|
||||||
<param name="dynamicColumnConfig"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:IRaCIS.Core.Application.Service.ExcelExportHelper.ExportTemplateAsync(IRaCIS.Application.Contracts.ExportTemplateServiceDto)">
|
<member name="M:IRaCIS.Core.Application.Service.ExcelExportHelper.ExportTemplateAsync(IRaCIS.Application.Contracts.ExportTemplateServiceDto)">
|
||||||
<summary>
|
<summary>
|
||||||
导出文件模板
|
导出文件模板
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,9 @@
|
||||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
using DocumentFormat.OpenXml.Vml;
|
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
|
||||||
using IRaCIS.Application.Contracts;
|
|
||||||
using IRaCIS.Core.Application.Contracts;
|
|
||||||
using IRaCIS.Core.Application.Helper;
|
|
||||||
using IRaCIS.Core.Application.MassTransit.Command;
|
|
||||||
using IRaCIS.Core.Domain;
|
using IRaCIS.Core.Domain;
|
||||||
using IRaCIS.Core.Domain.BaseModel;
|
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Microsoft.AspNetCore.Components.Routing;
|
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using NPOI.Util;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.MassTransit.Consumer;
|
namespace IRaCIS.Core.Application.MassTransit.Consumer;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
using System.Globalization;
|
using IRaCIS.Core.Domain.BaseModel;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using IRaCIS.Core.Domain.BaseModel;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using NPOI.SS.Formula.Functions;
|
using System.Globalization;
|
||||||
|
|
||||||
public class CultureInfoFilter<T> (IRepository<EventStoreRecord> _eventStoreRecordRepository) : IFilter<ConsumeContext<T>> where T : DomainEvent
|
public class CultureInfoFilter<T> (IRepository<EventStoreRecord> _eventStoreRecordRepository) : IFilter<ConsumeContext<T>> where T : DomainEvent
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,13 @@
|
||||||
using DocumentFormat.OpenXml;
|
using DocumentFormat.OpenXml;
|
||||||
using IRaCIS.Application.Contracts;
|
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Helper;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Application.MassTransit.Consumer;
|
using IRaCIS.Core.Application.MassTransit.Consumer;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Dynamic.Core;
|
using System.Linq.Dynamic.Core;
|
||||||
using System.Reactive.Joins;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.MassTransit.Recurring
|
namespace IRaCIS.Core.Application.MassTransit.Recurring
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,13 @@
|
||||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
using IRaCIS.Core.Application.Helper;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using MailKit;
|
using MailKit;
|
||||||
using MailKit.Net.Imap;
|
using MailKit.Net.Imap;
|
||||||
using MailKit.Search;
|
using MailKit.Search;
|
||||||
using MailKit.Security;
|
using MailKit.Security;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Contracts
|
namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,15 @@
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
using ClosedXML.Excel;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
using IRaCIS.Application.Contracts;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Application.Interfaces;
|
|
||||||
using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson;
|
using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson;
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Contracts.DTO;
|
using IRaCIS.Core.Application.Contracts.DTO;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using IRaCIS.Core.Infra.EFCore.Migrations;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
||||||
using NPOI.HPSF;
|
|
||||||
using NPOI.POIFS.Properties;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using NPOI.XSSF.UserModel;
|
|
||||||
using System.ComponentModel.Design;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using static IRaCIS.Core.Application.Service.ExcelExportHelper;
|
using static IRaCIS.Core.Application.Service.ExcelExportHelper;
|
||||||
|
|
@ -153,9 +141,9 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
|
|
||||||
var dynamicColumnConfig = new DynamicColumnConfig()
|
var dynamicColumnConfig = new DynamicColumnConfig()
|
||||||
{
|
{
|
||||||
AutoColumnTitleRowIndex = 2,
|
AutoColumnTitleRowIndex = 3, //2
|
||||||
AutoColumnStartIndex = 7,
|
AutoColumnStartIndex = 8, //7
|
||||||
TempalteLastColumnIndex = 6,
|
TempalteLastColumnIndex = 7, //6
|
||||||
DynamicItemDicName = "TranslateDicName",
|
DynamicItemDicName = "TranslateDicName",
|
||||||
DynamicItemValueName = "Answer",
|
DynamicItemValueName = "Answer",
|
||||||
DynamicItemTitleName = "QuestionName",
|
DynamicItemTitleName = "QuestionName",
|
||||||
|
|
@ -1242,52 +1230,57 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(StaticData.Export.TrialSubjectProgressList_Export, exportInfo, /*"", */_commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SubjectProgressDto));
|
var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(StaticData.Export.TrialSubjectProgressList_Export, exportInfo, /*"", */_commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SubjectProgressDto));
|
||||||
|
|
||||||
|
|
||||||
// 使用NPOI 进行二次处理
|
// 使用 ClosedXML 进行二次处理
|
||||||
|
using var workbook = new XLWorkbook(memoryStream);
|
||||||
var wb = new XSSFWorkbook(memoryStream);
|
var worksheet = workbook.Worksheet(1); // 获取第一个工作表,索引从1开始
|
||||||
|
|
||||||
var sheet = wb.GetSheetAt(0);
|
|
||||||
|
|
||||||
foreach (var subject in list)
|
foreach (var subject in list)
|
||||||
{
|
{
|
||||||
var index = list.IndexOf(subject);
|
var index = list.IndexOf(subject);
|
||||||
var row = sheet.GetRow(index + 4);
|
|
||||||
|
// ClosedXML 行索引从1开始,原来 NPOI 从0开始,所以 +1
|
||||||
|
var row = worksheet.Row(index + 4 + 1); // NPOI: index + 4, ClosedXML: +1 = index + 5
|
||||||
|
|
||||||
|
|
||||||
foreach (var item in subject.TotalList)
|
foreach (var item in subject.TotalList)
|
||||||
{
|
{
|
||||||
//从第五列开始动态写
|
// 从第五列开始动态写(ClosedXML 列索引从1开始)
|
||||||
var visitIndex = subject.TotalList.IndexOf(item) + 4;
|
var visitIndex = subject.TotalList.IndexOf(item) + 4 + 1; // NPOI: +4, ClosedXML: +1 = +5
|
||||||
|
|
||||||
var cell = row.CreateCell(visitIndex);
|
var cell = row.Cell(visitIndex);
|
||||||
|
|
||||||
if (item.IsLostVisit == true)
|
if (item.IsLostVisit == true)
|
||||||
{
|
{
|
||||||
cell.CellStyle = sheet.GetRow(1).GetCell(7).CellStyle;
|
//cell.CellStyle = sheet.GetRow(1).GetCell(7).CellStyle;
|
||||||
|
|
||||||
|
// 复制样式 - ClosedXML 需要先获取源样式,然后应用到目标单元格
|
||||||
|
var sourceCell = worksheet.Row(2).Cell(8); // 原 NPOI: GetRow(1).GetCell(7) -> +1 转换
|
||||||
|
|
||||||
|
cell.Style = sourceCell.Style;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (item.ReadingStatus)
|
switch (item.ReadingStatus)
|
||||||
{
|
{
|
||||||
case ReadingStatusEnum.ImageNotSubmit:
|
case ReadingStatusEnum.ImageNotSubmit:
|
||||||
|
cell.Style = worksheet.Row(2).Cell(2).Style; // NPOI: (1,1) -> ClosedXML: (2,2)
|
||||||
cell.CellStyle = sheet.GetRow(1).GetCell(1).CellStyle;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ReadingStatusEnum.ImageQuality:
|
case ReadingStatusEnum.ImageQuality:
|
||||||
cell.CellStyle = sheet.GetRow(1).GetCell(2).CellStyle;
|
cell.Style = worksheet.Row(2).Cell(3).Style; // (1,2) -> (2,3)
|
||||||
break;
|
break;
|
||||||
case ReadingStatusEnum.ConsistencyCheck:
|
case ReadingStatusEnum.ConsistencyCheck:
|
||||||
cell.CellStyle = sheet.GetRow(1).GetCell(3).CellStyle;
|
cell.Style = worksheet.Row(2).Cell(4).Style; // (1,3) -> (2,4)
|
||||||
break;
|
break;
|
||||||
case ReadingStatusEnum.TaskAllocate:
|
case ReadingStatusEnum.TaskAllocate:
|
||||||
cell.CellStyle = sheet.GetRow(1).GetCell(4).CellStyle;
|
cell.Style = worksheet.Row(2).Cell(5).Style;// (1,4) -> (2,5)
|
||||||
break;
|
break;
|
||||||
case ReadingStatusEnum.ImageReading:
|
case ReadingStatusEnum.ImageReading:
|
||||||
cell.CellStyle = sheet.GetRow(1).GetCell(5).CellStyle;
|
cell.Style = worksheet.Row(2).Cell(6).Style;// (1,5) -> (2,6)
|
||||||
break;
|
break;
|
||||||
case ReadingStatusEnum.ReadCompleted:
|
case ReadingStatusEnum.ReadCompleted:
|
||||||
cell.CellStyle = sheet.GetRow(1).GetCell(6).CellStyle;
|
cell.Style = worksheet.Row(2).Cell(7).Style; // (1,6) -> (2,7)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -1297,12 +1290,13 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cell.SetCellValue(item.TaskName);
|
cell.SetValue(item.TaskName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 保存到 MemoryStream
|
||||||
var memoryStream2 = new MemoryStream();
|
var memoryStream2 = new MemoryStream();
|
||||||
wb.Write(memoryStream2, true);
|
workbook.SaveAs(memoryStream2);
|
||||||
memoryStream2.Seek(0, SeekOrigin.Begin);
|
memoryStream2.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
return new FileStreamResult(memoryStream2, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
return new FileStreamResult(memoryStream2, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||||
|
|
@ -2709,9 +2703,10 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
var dynamicColumnConfig = new DynamicColumnConfig()
|
var dynamicColumnConfig = new DynamicColumnConfig()
|
||||||
{
|
{
|
||||||
//可读的列表名行索引,不是{{}} 模板行索引
|
//可读的列表名行索引,不是{{}} 模板行索引
|
||||||
AutoColumnTitleRowIndex = 2,
|
AutoColumnTitleRowIndex = 3, //2
|
||||||
AutoColumnStartIndex = 5,
|
AutoColumnStartIndex = 6, //5
|
||||||
TempalteLastColumnIndex = 4,
|
TempalteLastColumnIndex = 5, //4
|
||||||
|
|
||||||
DynamicItemDicName = "TranslateDicName",
|
DynamicItemDicName = "TranslateDicName",
|
||||||
DynamicItemValueName = "QuestionValue",
|
DynamicItemValueName = "QuestionValue",
|
||||||
DynamicItemTitleName = "QuestionName",
|
DynamicItemTitleName = "QuestionName",
|
||||||
|
|
@ -2867,7 +2862,8 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
if (!criterion.IsArbitrationReading)
|
if (!criterion.IsArbitrationReading)
|
||||||
{
|
{
|
||||||
//仲裁阅片 才有裁判阅片明细表 同时要把模板里面的三列给去掉
|
//仲裁阅片 才有裁判阅片明细表 同时要把模板里面的三列给去掉
|
||||||
removeColumnIndexList = new List<int>() { 6, 7, 8 };
|
//removeColumnIndexList = new List<int>() { 6, 7, 8 };
|
||||||
|
removeColumnIndexList = new List<int>() { 7, 8 ,9};
|
||||||
}
|
}
|
||||||
|
|
||||||
//阅片结果表 和阅片结果明细表 没有肿瘤学的时候需要移除肿瘤学三个字段
|
//阅片结果表 和阅片结果明细表 没有肿瘤学的时候需要移除肿瘤学三个字段
|
||||||
|
|
@ -2876,7 +2872,8 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
{
|
{
|
||||||
if (inQuery.ReadingExportType == ExportResult.TableOfAssessmentResults || inQuery.ReadingExportType == ExportResult.DetailedTableOfAssessmentResults)
|
if (inQuery.ReadingExportType == ExportResult.TableOfAssessmentResults || inQuery.ReadingExportType == ExportResult.DetailedTableOfAssessmentResults)
|
||||||
{
|
{
|
||||||
removeColumnIndexList = removeColumnIndexList.Union(new List<int>() { 9, 10, 11 }).ToList();
|
//removeColumnIndexList = removeColumnIndexList.Union(new List<int>() { 9, 10, 11 }).ToList();
|
||||||
|
removeColumnIndexList = removeColumnIndexList.Union(new List<int>() { 10, 11, 12 }).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3170,7 +3167,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
addLessionInfoList.Add(new CommonQuesionInfo() { QuestionName = _userInfo.IsEn_Us ? "Lesion Type" : "病灶类型", QuestionValue = lession.LessionType, TranslateDicName = "LesionType" });
|
addLessionInfoList.Add(new CommonQuesionInfo() { QuestionName = _userInfo.IsEn_Us ? "Lesion Type" : "病灶类型", QuestionValue = lession.LessionType, TranslateDicName = "LesionType" });
|
||||||
}
|
}
|
||||||
|
|
||||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.QuestionName, OptionTypeEnum = t.OptionTypeEnum, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName ,Unit=t.Unit});
|
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.QuestionName, OptionTypeEnum = t.OptionTypeEnum, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, Unit = t.Unit });
|
||||||
|
|
||||||
//有三部分组成 外层问题+ 没有配置病灶编号和类型+ 动态的表格问题
|
//有三部分组成 外层问题+ 没有配置病灶编号和类型+ 动态的表格问题
|
||||||
var dynamicLessionInfoList = item.QuestionAnswerList.Union(addLessionInfoList).Union(dynamicPartialLessionInfoList).ToList();
|
var dynamicLessionInfoList = item.QuestionAnswerList.Union(addLessionInfoList).Union(dynamicPartialLessionInfoList).ToList();
|
||||||
|
|
@ -3358,9 +3355,10 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
|
|
||||||
dynamicColumnConfig = new DynamicColumnConfig()
|
dynamicColumnConfig = new DynamicColumnConfig()
|
||||||
{
|
{
|
||||||
AutoColumnTitleRowIndex = 2,
|
|
||||||
AutoColumnStartIndex = 6,
|
AutoColumnTitleRowIndex = 3, //2
|
||||||
TempalteLastColumnIndex = 11,
|
AutoColumnStartIndex = 7, //6
|
||||||
|
TempalteLastColumnIndex = 12,//11
|
||||||
DynamicItemDicName = "TranslateDicName",
|
DynamicItemDicName = "TranslateDicName",
|
||||||
DynamicItemValueName = "QuestionValue",
|
DynamicItemValueName = "QuestionValue",
|
||||||
DynamicItemTitleName = "QuestionName",
|
DynamicItemTitleName = "QuestionName",
|
||||||
|
|
@ -3372,7 +3370,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
TranslateDicNameList = translateDicNameList
|
TranslateDicNameList = translateDicNameList
|
||||||
};
|
};
|
||||||
|
|
||||||
if (export_Template == StaticData.Export.ReadingLession_Export || export_Template == StaticData.Export.CommonJudgeReadingDetail_Export || export_Template== StaticData.Export.OCT_ReadingLession_Export)
|
if (export_Template == StaticData.Export.ReadingLession_Export || export_Template == StaticData.Export.CommonJudgeReadingDetail_Export || export_Template == StaticData.Export.OCT_ReadingLession_Export)
|
||||||
{
|
{
|
||||||
dynamicColumnConfig.TempalteLastColumnIndex = 8;
|
dynamicColumnConfig.TempalteLastColumnIndex = 8;
|
||||||
}
|
}
|
||||||
|
|
@ -3435,7 +3433,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
var dynamicLessionInfoList = new List<CommonQuesionInfo>();
|
var dynamicLessionInfoList = new List<CommonQuesionInfo>();
|
||||||
|
|
||||||
|
|
||||||
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId,OptionTypeEnum=t.OptionTypeEnum, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode, Unit = t.Unit });
|
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, OptionTypeEnum = t.OptionTypeEnum, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode, Unit = t.Unit });
|
||||||
|
|
||||||
//两部分组成 外层问题+ 动态的表格问题
|
//两部分组成 外层问题+ 动态的表格问题
|
||||||
dynamicLessionInfoList = item.QuestionAnswerList.Union(dynamicPartialLessionInfoList).ToList();
|
dynamicLessionInfoList = item.QuestionAnswerList.Union(dynamicPartialLessionInfoList).ToList();
|
||||||
|
|
@ -3458,9 +3456,9 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
|
|
||||||
dynamicColumnConfig = new DynamicColumnConfig()
|
dynamicColumnConfig = new DynamicColumnConfig()
|
||||||
{
|
{
|
||||||
AutoColumnTitleRowIndex = 1,
|
AutoColumnTitleRowIndex = 2, //1
|
||||||
AutoColumnStartIndex = 6,
|
AutoColumnStartIndex = 7, //6
|
||||||
TempalteLastColumnIndex = 10,
|
TempalteLastColumnIndex = 11, //10
|
||||||
DynamicItemDicName = "TranslateDicName",
|
DynamicItemDicName = "TranslateDicName",
|
||||||
DynamicItemValueName = "QuestionValue",
|
DynamicItemValueName = "QuestionValue",
|
||||||
DynamicItemTitleName = "QuestionName",
|
DynamicItemTitleName = "QuestionName",
|
||||||
|
|
@ -3543,9 +3541,9 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
|
|
||||||
dynamicColumnConfig = new DynamicColumnConfig()
|
dynamicColumnConfig = new DynamicColumnConfig()
|
||||||
{
|
{
|
||||||
AutoColumnTitleRowIndex = 1,
|
AutoColumnTitleRowIndex = 2, //1
|
||||||
AutoColumnStartIndex = 6,
|
AutoColumnStartIndex = 7, //6
|
||||||
TempalteLastColumnIndex = 15,
|
TempalteLastColumnIndex = 16, //15
|
||||||
DynamicItemDicName = "TranslateDicName",
|
DynamicItemDicName = "TranslateDicName",
|
||||||
DynamicItemValueName = "QuestionValue",
|
DynamicItemValueName = "QuestionValue",
|
||||||
DynamicItemTitleName = "QuestionName",
|
DynamicItemTitleName = "QuestionName",
|
||||||
|
|
@ -3578,9 +3576,9 @@ namespace IRaCIS.Core.Application.Service.Common
|
||||||
|
|
||||||
dynamicColumnConfig = new DynamicColumnConfig()
|
dynamicColumnConfig = new DynamicColumnConfig()
|
||||||
{
|
{
|
||||||
AutoColumnTitleRowIndex = 1,
|
AutoColumnTitleRowIndex = 2, //1
|
||||||
AutoColumnStartIndex = 6,
|
AutoColumnStartIndex = 7, //6
|
||||||
TempalteLastColumnIndex = 10,
|
TempalteLastColumnIndex = 11, //10
|
||||||
DynamicItemDicName = "TranslateDicName",
|
DynamicItemDicName = "TranslateDicName",
|
||||||
DynamicItemValueName = "QuestionValue",
|
DynamicItemValueName = "QuestionValue",
|
||||||
DynamicItemTitleName = "QuestionName",
|
DynamicItemTitleName = "QuestionName",
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,15 @@
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Application.Contracts;
|
|
||||||
using IRaCIS.Application.Interfaces;
|
using IRaCIS.Application.Interfaces;
|
||||||
using IRaCIS.Core.Application.Helper;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
|
||||||
using MassTransit;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using MiniExcelLibs;
|
using MiniExcelLibs;
|
||||||
using MiniExcelLibs.OpenXml;
|
using MiniExcelLibs.OpenXml;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using Org.BouncyCastle.Asn1.X509;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service.Common;
|
namespace IRaCIS.Core.Application.Service.Common;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,9 @@
|
||||||
using Amazon.Runtime.Internal.Transform;
|
using IRaCIS.Application.Contracts;
|
||||||
using DocumentFormat.OpenXml.Bibliography;
|
|
||||||
using DocumentFormat.OpenXml.Office2010.CustomUI;
|
|
||||||
using DocumentFormat.OpenXml.Office2021.DocumentTasks;
|
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
using IRaCIS.Application.Contracts;
|
|
||||||
using IRaCIS.Application.Interfaces;
|
using IRaCIS.Application.Interfaces;
|
||||||
using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson;
|
|
||||||
using IRaCIS.Core.Application.Contracts;
|
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using MailKit;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using NetTopologySuite.Triangulate.Tri;
|
|
||||||
using NPOI.OpenXmlFormats.Spreadsheet;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using NPOI.Util;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using static IRaCIS.Core.Application.Service.ExcelExportHelper;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service.Common;
|
namespace IRaCIS.Core.Application.Service.Common;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,26 +4,10 @@
|
||||||
// 生成时间 2025-03-27 06:13:33Z
|
// 生成时间 2025-03-27 06:13:33Z
|
||||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using IRaCIS.Core.Application.Interfaces;
|
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using IRaCIS.Core.Infra.EFCore;
|
|
||||||
using AutoMapper.Execution;
|
|
||||||
using System.Linq;
|
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using NPOI.POIFS.Properties;
|
|
||||||
using Org.BouncyCastle.Crypto;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using IRaCIS.Core.Application.Contracts;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using EFCore.BulkExtensions;
|
|
||||||
namespace IRaCIS.Core.Application.Service;
|
namespace IRaCIS.Core.Application.Service;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,10 @@
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Filter;
|
|
||||||
using IRaCIS.Core.Application.MassTransit.Consumer;
|
using IRaCIS.Core.Application.MassTransit.Consumer;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using MassTransit.Mediator;
|
using MassTransit.Mediator;
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Dynamic.Core;
|
using System.Linq.Dynamic.Core;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Services
|
namespace IRaCIS.Core.Application.Services
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,18 @@
|
||||||
using DocumentFormat.OpenXml.EMMA;
|
using FellowOakDicom;
|
||||||
using FellowOakDicom;
|
|
||||||
using FellowOakDicom.Media;
|
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Contracts.Dicom.DTO;
|
using IRaCIS.Core.Application.Contracts.Dicom.DTO;
|
||||||
using IRaCIS.Core.Application.Filter;
|
|
||||||
using IRaCIS.Core.Application.Helper;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Application.Service.ImageAndDoc.DTO;
|
using IRaCIS.Core.Application.Service.ImageAndDoc.DTO;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using MassTransit.Initializers;
|
using MassTransit.Initializers;
|
||||||
using MathNet.Numerics;
|
|
||||||
using Medallion.Threading;
|
using Medallion.Threading;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NetTopologySuite.Mathematics;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.IO;
|
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using ZiggyCreatures.Caching.Fusion;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,9 @@
|
||||||
// 生成时间 2021-12-06 10:54:55
|
// 生成时间 2021-12-06 10:54:55
|
||||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
using DocumentFormat.OpenXml.EMMA;
|
|
||||||
using IRaCIS.Core.Application.Filter;
|
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using Medallion.Threading;
|
using Medallion.Threading;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Contracts
|
namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,8 @@
|
||||||
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Application.Contracts;
|
|
||||||
using IRaCIS.Core.Application.Service.DTO;
|
using IRaCIS.Core.Application.Service.DTO;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using NPOI.HPSF;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,10 @@
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Contracts.DTO;
|
using IRaCIS.Core.Application.Contracts.DTO;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
|
||||||
using MassTransit.Initializers;
|
using MassTransit.Initializers;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Image.QA
|
namespace IRaCIS.Core.Application.Image.QA
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
using AutoMapper;
|
using AutoMapper.EquivalencyExpression;
|
||||||
using AutoMapper.EquivalencyExpression;
|
|
||||||
using IRaCIS.Application.Contracts;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Contracts.DTO;
|
using IRaCIS.Core.Application.Contracts.DTO;
|
||||||
using IRaCIS.Core.Application.MassTransit.Command;
|
using IRaCIS.Core.Application.MassTransit.Command;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Migrations;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Filter;
|
|
||||||
using IRaCIS.Core.Application.Interfaces;
|
using IRaCIS.Core.Application.Interfaces;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using Panda.DynamicWebApi.Attributes;
|
using Panda.DynamicWebApi.Attributes;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,19 @@
|
||||||
using Amazon.Runtime.Internal.Transform;
|
using DocumentFormat.OpenXml;
|
||||||
using DocumentFormat.OpenXml;
|
|
||||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
||||||
using DocumentFormat.OpenXml.Office2019.Excel.ThreadedComments;
|
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Filter;
|
|
||||||
using IRaCIS.Core.Application.Helper;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Application.Interfaces;
|
using IRaCIS.Core.Application.Interfaces;
|
||||||
using IRaCIS.Core.Application.Service.ImageAndDoc;
|
using IRaCIS.Core.Application.Service.ImageAndDoc;
|
||||||
using IRaCIS.Core.Application.Service.OAuth;
|
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Application.Service.ReadingCalculate.Interface;
|
using IRaCIS.Core.Application.Service.ReadingCalculate.Interface;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Newtonsoft.Json.Serialization;
|
|
||||||
using NPOI.POIFS.Properties;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using Panda.DynamicWebApi.Attributes;
|
using Panda.DynamicWebApi.Attributes;
|
||||||
using System.Linq;
|
|
||||||
using ZiggyCreatures.Caching.Fusion;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
using DocumentFormat.OpenXml.Office2019.Excel.ThreadedComments;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Contracts;
|
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NPOI.POIFS.Properties;
|
|
||||||
using Panda.DynamicWebApi.Attributes;
|
using Panda.DynamicWebApi.Attributes;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,9 @@
|
||||||
using DocumentFormat.OpenXml.Drawing;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Contracts;
|
|
||||||
using IRaCIS.Core.Application.Filter;
|
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NPOI.Util;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,11 @@
|
||||||
using DocumentFormat.OpenXml.EMMA;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using DocumentFormat.OpenXml.Presentation;
|
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using MathNet.Numerics;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using MiniExcelLibs;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
using DocumentFormat.OpenXml.EMMA;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NPOI.Util;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,36 +3,17 @@
|
||||||
// 生成时间 2021-12-23 13:20:59
|
// 生成时间 2021-12-23 13:20:59
|
||||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
using DocumentFormat.OpenXml.Vml.Spreadsheet;
|
|
||||||
using IdentityModel;
|
|
||||||
using IdentityModel.OidcClient;
|
|
||||||
using IRaCIS.Application.Contracts;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Auth;
|
using IRaCIS.Core.Application.Auth;
|
||||||
using IRaCIS.Core.Application.Filter;
|
|
||||||
using IRaCIS.Core.Application.Helper;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Application.Service;
|
|
||||||
using IRaCIS.Core.Application.Service.OAuth;
|
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Medallion.Threading;
|
using Medallion.Threading;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Components.Routing;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.VisualBasic;
|
|
||||||
using MimeKit;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using Panda.DynamicWebApi.Attributes;
|
|
||||||
using StackExchange.Redis;
|
|
||||||
using System.Security.Policy;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using static MassTransit.ValidationResultExtensions;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Contracts
|
namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,8 @@
|
||||||
using FellowOakDicom;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Application.Contracts;
|
|
||||||
using IRaCIS.Application.Interfaces;
|
using IRaCIS.Application.Interfaces;
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Contracts.DTO;
|
using IRaCIS.Core.Application.Contracts.DTO;
|
||||||
using IRaCIS.Core.Application.Filter;
|
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
|
||||||
using MassTransit.Serialization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.Json;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,11 @@
|
||||||
using DocumentFormat.OpenXml.Office2010.ExcelAc;
|
using IRaCIS.Application.Contracts;
|
||||||
using IRaCIS.Application.Contracts;
|
|
||||||
using IRaCIS.Application.Interfaces;
|
using IRaCIS.Application.Interfaces;
|
||||||
using IRaCIS.Core.Application.Filter;
|
|
||||||
using IRaCIS.Core.Application.Helper;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using Panda.DynamicWebApi.Attributes;
|
using Panda.DynamicWebApi.Attributes;
|
||||||
using ZiggyCreatures.Caching.Fusion;
|
|
||||||
using static IRaCIS.Core.Domain.Share.StaticData;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,6 @@
|
||||||
using IRaCIS.Application.Contracts;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using IRaCIS.Core.Application.Contracts;
|
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using static IRaCIS.Core.Application.Service.ExcelExportHelper;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application;
|
namespace IRaCIS.Core.Application;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using MiniExcelLibs;
|
using MiniExcelLibs;
|
||||||
using NPOI.XWPF.UserModel;
|
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
|
@ -1211,115 +1210,115 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[AllowAnonymous]
|
//[AllowAnonymous]
|
||||||
public async Task<string> testDoc([FromServices] IWebHostEnvironment env, string email)
|
//public async Task<string> testDoc([FromServices] IWebHostEnvironment env, string email)
|
||||||
{
|
|
||||||
#region DocX 测试
|
|
||||||
//using (DocX document = DocX.Load("C:\\Users\\hang\\Desktop\\test.docx"))
|
|
||||||
//{
|
//{
|
||||||
// // 查找书签
|
// #region DocX 测试
|
||||||
// var bookmarkCn_Start = document.Bookmarks.FirstOrDefault(b => b.Name == "zh_cn");
|
// //using (DocX document = DocX.Load("C:\\Users\\hang\\Desktop\\test.docx"))
|
||||||
// var bookmarkEn_Start = document.Bookmarks.FirstOrDefault(b => b.Name == "en_us");
|
// //{
|
||||||
|
// // // 查找书签
|
||||||
|
// // var bookmarkCn_Start = document.Bookmarks.FirstOrDefault(b => b.Name == "zh_cn");
|
||||||
|
// // var bookmarkEn_Start = document.Bookmarks.FirstOrDefault(b => b.Name == "en_us");
|
||||||
|
|
||||||
// if (bookmarkCn_Start != null && bookmarkEn_Start != null)
|
// // if (bookmarkCn_Start != null && bookmarkEn_Start != null)
|
||||||
|
// // {
|
||||||
|
// // // 获取书签的起始位置
|
||||||
|
// // int bookmarkCNStartPos = bookmarkCn_Start.Paragraph.StartIndex;
|
||||||
|
|
||||||
|
// // var bookmarkENStartPos = bookmarkEn_Start.Paragraph.StartIndex;
|
||||||
|
|
||||||
|
// // // // 创建一个要删除段落的列表
|
||||||
|
// // List<Paragraph> paragraphsToRemove = new List<Paragraph>();
|
||||||
|
|
||||||
|
// // foreach (var item in document.Paragraphs)
|
||||||
|
// // {
|
||||||
|
|
||||||
|
// // //中文模板在前,英文在后,英文模板,就删除英文之前的,中文模板就删除英文之后的
|
||||||
|
// // //_userInfo.IsEn_Us? item.EndIndex< bookmarkENStartPos :item.StartIndex>= bookmarkENStartPos
|
||||||
|
// // if (item.StartIndex>= bookmarkENStartPos)
|
||||||
|
// // {
|
||||||
|
// // paragraphsToRemove.Add(item);
|
||||||
|
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // foreach (var paragraph in paragraphsToRemove)
|
||||||
|
// // {
|
||||||
|
// // document.RemoveParagraph(paragraph);
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // // 保存修改
|
||||||
|
// // document.SaveAs("C:\\Users\\hang\\Desktop\\test1.docx");
|
||||||
|
// //}
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// using (FileStream fs = new FileStream("C:\\Users\\hang\\Desktop\\test.docx", FileMode.Open, FileAccess.Read))
|
||||||
// {
|
// {
|
||||||
// // 获取书签的起始位置
|
// XWPFDocument doc = new XWPFDocument(fs);
|
||||||
// int bookmarkCNStartPos = bookmarkCn_Start.Paragraph.StartIndex;
|
|
||||||
|
|
||||||
// var bookmarkENStartPos = bookmarkEn_Start.Paragraph.StartIndex;
|
|
||||||
|
|
||||||
// // // 创建一个要删除段落的列表
|
// // 查找包含指定书签的段落及其索引
|
||||||
// List<Paragraph> paragraphsToRemove = new List<Paragraph>();
|
// var bookmarkParagraph = doc.Paragraphs
|
||||||
|
// .FirstOrDefault(p => p.GetCTP().GetBookmarkStartList().Any(b => b.name == "en_us"));
|
||||||
|
|
||||||
// foreach (var item in document.Paragraphs)
|
|
||||||
|
// if (bookmarkParagraph != null)
|
||||||
// {
|
// {
|
||||||
|
// int bookmarkIndex = doc.Paragraphs.IndexOf(bookmarkParagraph);
|
||||||
|
|
||||||
// //中文模板在前,英文在后,英文模板,就删除英文之前的,中文模板就删除英文之后的
|
// // 删除书签之后的所有段落
|
||||||
// //_userInfo.IsEn_Us? item.EndIndex< bookmarkENStartPos :item.StartIndex>= bookmarkENStartPos
|
// for (int i = doc.Paragraphs.Count - 1; i >= bookmarkIndex; i--)
|
||||||
// if (item.StartIndex>= bookmarkENStartPos)
|
|
||||||
// {
|
// {
|
||||||
// paragraphsToRemove.Add(item);
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// foreach (var paragraph in paragraphsToRemove)
|
|
||||||
// {
|
|
||||||
// document.RemoveParagraph(paragraph);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 保存修改
|
|
||||||
// document.SaveAs("C:\\Users\\hang\\Desktop\\test1.docx");
|
|
||||||
//}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using (FileStream fs = new FileStream("C:\\Users\\hang\\Desktop\\test.docx", FileMode.Open, FileAccess.Read))
|
|
||||||
{
|
|
||||||
XWPFDocument doc = new XWPFDocument(fs);
|
|
||||||
|
|
||||||
|
|
||||||
// 查找包含指定书签的段落及其索引
|
|
||||||
var bookmarkParagraph = doc.Paragraphs
|
|
||||||
.FirstOrDefault(p => p.GetCTP().GetBookmarkStartList().Any(b => b.name == "en_us"));
|
|
||||||
|
|
||||||
|
|
||||||
if (bookmarkParagraph != null)
|
|
||||||
{
|
|
||||||
int bookmarkIndex = doc.Paragraphs.IndexOf(bookmarkParagraph);
|
|
||||||
|
|
||||||
// 删除书签之后的所有段落
|
|
||||||
for (int i = doc.Paragraphs.Count - 1; i >= bookmarkIndex; i--)
|
|
||||||
{
|
|
||||||
doc.RemoveBodyElement(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new BusinessValidationFailedException("word 模板没有英文书签");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建一个要删除段落的列表
|
|
||||||
|
|
||||||
//XWPFParagraph bookmarkParagraph = null;
|
|
||||||
|
|
||||||
//foreach (var paragraph in doc.Paragraphs)
|
|
||||||
//{
|
|
||||||
|
|
||||||
// foreach (var bookmark in paragraph.GetCTP().GetBookmarkStartList())
|
|
||||||
// {
|
|
||||||
// if (bookmark.name == "en_us")
|
|
||||||
// {
|
|
||||||
// bookmarkParagraph = paragraph;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// 从书签所在段落开始,删除之前的所有段落
|
|
||||||
//for (int i = bookmarkIndex - 1; i >= 0; i--)
|
|
||||||
//{
|
|
||||||
// doc.RemoveBodyElement(i);
|
// doc.RemoveBodyElement(i);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// throw new BusinessValidationFailedException("word 模板没有英文书签");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 创建一个要删除段落的列表
|
||||||
|
|
||||||
|
// //XWPFParagraph bookmarkParagraph = null;
|
||||||
|
|
||||||
|
// //foreach (var paragraph in doc.Paragraphs)
|
||||||
|
// //{
|
||||||
|
|
||||||
|
// // foreach (var bookmark in paragraph.GetCTP().GetBookmarkStartList())
|
||||||
|
// // {
|
||||||
|
// // if (bookmark.name == "en_us")
|
||||||
|
// // {
|
||||||
|
// // bookmarkParagraph = paragraph;
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// //}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// //// 从书签所在段落开始,删除之前的所有段落
|
||||||
|
// //for (int i = bookmarkIndex - 1; i >= 0; i--)
|
||||||
|
// //{
|
||||||
|
// // doc.RemoveBodyElement(i);
|
||||||
|
// //}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// using (FileStream outStream = new FileStream("C:\\Users\\hang\\Desktop\\test1.docx", FileMode.Create, FileAccess.Write))
|
||||||
|
// {
|
||||||
|
// doc.Write(outStream);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// return "hiddenEmail";
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using (FileStream outStream = new FileStream("C:\\Users\\hang\\Desktop\\test1.docx", FileMode.Create, FileAccess.Write))
|
|
||||||
{
|
|
||||||
doc.Write(outStream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return "hiddenEmail";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<object> GetEnvironmentName([FromServices] IWebHostEnvironment env)
|
public async Task<object> GetEnvironmentName([FromServices] IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue