术语替换-先完整准确匹配,匹配了就跳过,否则就关键字匹配替换
continuous-integration/drone/push Build is running
Details
continuous-integration/drone/push Build is running
Details
parent
152a142d82
commit
2b03f382bd
|
|
@ -166,6 +166,31 @@ public static class ExcelExportHelper
|
|||
// ClosedXML 获取第一个工作表
|
||||
var worksheet = workbook.Worksheet(1); // 索引从1开始
|
||||
|
||||
#region sheet 名字修改 以及导表文件名字修改
|
||||
|
||||
var currentSheetName = worksheet.Name;
|
||||
|
||||
// 查找匹配的工作表名(支持部分匹配)
|
||||
var findObj = replaceObjectList.FirstOrDefault(t => currentSheetName.Contains(t.Name));
|
||||
|
||||
if (findObj != null)
|
||||
{
|
||||
// 直接匹配或替换包含关键字的工作表名
|
||||
var newSheetName = currentSheetName.Replace(findObj.Name, findObj.TrialName);
|
||||
worksheet.Name = newSheetName;
|
||||
}
|
||||
|
||||
|
||||
var findFileName = replaceObjectList.FirstOrDefault(t => fileName.Contains(t.Name));
|
||||
|
||||
if (findFileName != null)
|
||||
{
|
||||
// 直接匹配或替换包含关键字的工作表名
|
||||
var newFileName = currentSheetName.Replace(findFileName.Name, findFileName.TrialName);
|
||||
fileName = newFileName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
// 获取使用的行范围(不包括空行)
|
||||
var rowsUsed = worksheet.RowsUsed();
|
||||
|
||||
|
|
@ -178,11 +203,35 @@ public static class ExcelExportHelper
|
|||
{
|
||||
var cellValue = cell.GetString();
|
||||
|
||||
var find = replaceObjectList.FirstOrDefault(t => t.Name == cellValue);
|
||||
var newValue = cellValue;
|
||||
var isChanged = false;
|
||||
|
||||
var find = replaceObjectList.FirstOrDefault(t => cellValue.Trim() == t.Name.Trim());
|
||||
|
||||
if (find != null)
|
||||
{
|
||||
cell.SetValue(find.TrialName);
|
||||
newValue = newValue.Replace(find.Name, find.TrialName);
|
||||
|
||||
isChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 遍历所有替换规则,进行关键字匹配替换
|
||||
foreach (var replaceItem in replaceObjectList.Where(t => cellValue.Contains(t.Name)))
|
||||
{
|
||||
|
||||
newValue = newValue.Replace(replaceItem.Name, replaceItem.TrialName);
|
||||
isChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isChanged)
|
||||
{
|
||||
cell.SetValue(newValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -305,7 +354,7 @@ public static class ExcelExportHelper
|
|||
}
|
||||
|
||||
|
||||
public static async Task<(MemoryStream, string)> DataExport_NpoiTestAsync(string code, ExcelExportInfo data, IRepository<CommonDocument> _commonDocumentRepository, IWebHostEnvironment _hostEnvironment, IDictionaryService? _dictionaryService = null, Type? translateType = null, CriterionType? criterionType = null, DynamicColumnConfig? dynamicColumnConfig = null)
|
||||
public static async Task<(MemoryStream, string)> DataExport_ClosedXMLAsync(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;
|
||||
//判断是否有字典翻译
|
||||
|
|
@ -444,30 +493,76 @@ public static class ExcelExportHelper
|
|||
// ClosedXML 获取第一个工作表
|
||||
var worksheet = workbook.Worksheet(1); // 索引从1开始
|
||||
|
||||
#region sheet 名字修改 以及导表文件名字修改
|
||||
|
||||
var currentSheetName = worksheet.Name;
|
||||
|
||||
// 查找匹配的工作表名(支持部分匹配)
|
||||
var findObj = replaceObjectList.FirstOrDefault(t => currentSheetName.Contains(t.Name));
|
||||
|
||||
if (findObj != null)
|
||||
{
|
||||
// 直接匹配或替换包含关键字的工作表名
|
||||
var newSheetName = currentSheetName.Replace(findObj.Name, findObj.TrialName);
|
||||
worksheet.Name = newSheetName;
|
||||
}
|
||||
|
||||
|
||||
var findFileName = replaceObjectList.FirstOrDefault(t => fileName.Contains(t.Name));
|
||||
|
||||
if (findFileName != null)
|
||||
{
|
||||
// 直接匹配或替换包含关键字的工作表名
|
||||
var newFileName = currentSheetName.Replace(findFileName.Name, findFileName.TrialName);
|
||||
fileName = newFileName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
// 获取使用的行范围(不包括空行)
|
||||
var rowsUsed = worksheet.RowsUsed();
|
||||
|
||||
foreach (var row in rowsUsed)
|
||||
{
|
||||
// 获取该行使用的列范围
|
||||
var cellsUsed = row.CellsUsed();
|
||||
// 获取该行有数据的单元格
|
||||
var cellsUsed = row.CellsUsed(c => c.DataType == XLDataType.Text);
|
||||
|
||||
foreach (var cell in cellsUsed)
|
||||
{
|
||||
|
||||
var cellValue = cell.GetString();
|
||||
|
||||
var find = replaceObjectList.FirstOrDefault(t => t.Name == cellValue);
|
||||
var newValue = cellValue;
|
||||
var isChanged = false;
|
||||
|
||||
var find = replaceObjectList.FirstOrDefault(t => cellValue.Trim() == t.Name.Trim());
|
||||
|
||||
if (find != null)
|
||||
{
|
||||
cell.SetValue(find.TrialName);
|
||||
newValue = newValue.Replace(find.Name, find.TrialName);
|
||||
|
||||
isChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 遍历所有替换规则,进行关键字匹配替换
|
||||
foreach (var replaceItem in replaceObjectList.Where(t => cellValue.Contains(t.Name)))
|
||||
{
|
||||
|
||||
newValue = newValue.Replace(replaceItem.Name, replaceItem.TrialName);
|
||||
isChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isChanged)
|
||||
{
|
||||
cell.SetValue(newValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17492,17 +17492,17 @@
|
|||
</member>
|
||||
<member name="F:IRaCIS.Core.Application.ViewModel.AccessToDialogueEnum.Question">
|
||||
<summary>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
质疑
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:IRaCIS.Core.Application.ViewModel.AccessToDialogueEnum.Consistency">
|
||||
<summary>
|
||||
һ<EFBFBD><EFBFBD><EFBFBD>Ժ˲<EFBFBD>
|
||||
一致性核查
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.ViewModel.CopyFrontAuditConfigItemDto">
|
||||
<summary>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
复制
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:IRaCIS.Core.Application.ViewModel.SystemNoticeView">
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
|||
};
|
||||
|
||||
|
||||
var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(StaticData.Export.TrialQCResult_Export, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(QCQuestionResult_Export), dynamicColumnConfig: dynamicColumnConfig);
|
||||
var (memoryStream, fileName) = await ExcelExportHelper.DataExport_ClosedXMLAsync(StaticData.Export.TrialQCResult_Export, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(QCQuestionResult_Export), dynamicColumnConfig: dynamicColumnConfig);
|
||||
|
||||
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
{
|
||||
|
|
@ -1227,7 +1227,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
|||
exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId);
|
||||
|
||||
|
||||
var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(StaticData.Export.TrialSubjectProgressList_Export, exportInfo, /*"", */_commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SubjectProgressDto));
|
||||
var (memoryStream, fileName) = await ExcelExportHelper.DataExport_ClosedXMLAsync(StaticData.Export.TrialSubjectProgressList_Export, exportInfo, /*"", */_commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SubjectProgressDto));
|
||||
|
||||
|
||||
// 使用 ClosedXML 进行二次处理
|
||||
|
|
@ -2717,7 +2717,7 @@ namespace IRaCIS.Core.Application.Service.Common
|
|||
};
|
||||
|
||||
|
||||
var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(AnalysisDynamicCommonExport), criterion.CriterionType, dynamicColumnConfig);
|
||||
var (memoryStream, fileName) = await ExcelExportHelper.DataExport_ClosedXMLAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(AnalysisDynamicCommonExport), criterion.CriterionType, dynamicColumnConfig);
|
||||
|
||||
return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
{
|
||||
|
|
@ -3648,12 +3648,12 @@ namespace IRaCIS.Core.Application.Service.Common
|
|||
|
||||
if (inQuery.ReadingExportType == ExportResult.NoneTumorCDISC)
|
||||
{
|
||||
(memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig);
|
||||
(memoryStream, fileName) = await ExcelExportHelper.DataExport_ClosedXMLAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
(memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig);
|
||||
(memoryStream, fileName) = await ExcelExportHelper.DataExport_ClosedXMLAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue