diff --git a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs index 6c6a4acae..5c740d0a5 100644 --- a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs @@ -18,6 +18,7 @@ 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.Globalization; using Xceed.Document.NET; @@ -870,17 +871,16 @@ public static class ExcelExportHelper //模板路径 var tplPath = physicalPath; - #region 根据中英文 删除模板sheet - - // 打开模板文件 - var templateFile = new FileStream(tplPath, FileMode.Open, FileAccess.Read); // 获取文件流 var templateStream = new MemoryStream(); - templateFile.CopyTo(templateStream); - templateStream.Seek(0, SeekOrigin.Begin); - var workbook = new XSSFWorkbook(templateStream); + #region 根据中英文 删除模板sheet + + // 打开模板文件 + var templateFileStream = new FileStream(tplPath, FileMode.Open, FileAccess.Read); + + var workbook = new XSSFWorkbook(templateFileStream); int sheetCount = workbook.NumberOfSheets; @@ -985,14 +985,8 @@ public static class ExcelExportHelper } } - using (var memoryStream2 = new MemoryStream()) - { - workbook.Write(memoryStream2, true); - - memoryStream2.Seek(0, SeekOrigin.Begin); - - templateStream = memoryStream2; - } + workbook.Write(templateStream, leaveOpen: true); + templateStream.Position = 0; } @@ -1099,6 +1093,63 @@ public static class ExcelExportHelper //模板路径 var tplPath = physicalPath; + var templateStream = new MemoryStream(); + + + #region npoi 移除某一行 + var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US; + + if (isEn_US) + { + // 打开模板文件 + using var templateFileStream = new FileStream(tplPath, FileMode.Open, FileAccess.Read); + + using var workbook = new XSSFWorkbook(templateFileStream); + + int sheetCount = workbook.NumberOfSheets; + + int removeRowIndex = 1; // 要删除的行(0-based) + + for (int i = 0; i < sheetCount; i++) + { + var sheet = workbook.GetSheetAt(i); + + // 2️ 删除行 + var row = sheet.GetRow(removeRowIndex); + if (row != null) + { + sheet.RemoveRow(row); + } + + // 3️ 上移后续行 + if (removeRowIndex < sheet.LastRowNum) + { + sheet.ShiftRows( + removeRowIndex + 1, + sheet.LastRowNum, + -1, + true, // copyRowHeight + false // resetOriginalRowHeight + ); + } + } + + workbook.Write(templateStream, leaveOpen: true); + templateStream.Position = 0; + } + else + { + using (var fs = new FileStream(tplPath, FileMode.Open, FileAccess.Read)) + { + fs.CopyTo(templateStream); + } + + templateStream.Position = 0; + } + + + #endregion + var memoryStream = new MemoryStream(); @@ -1107,7 +1158,7 @@ public static class ExcelExportHelper IgnoreTemplateParameterMissing = true, }; - await MiniExcel.SaveAsByTemplateAsync(memoryStream, tplPath, data, config); + await MiniExcel.SaveAsByTemplateAsync(memoryStream, templateStream.ToArray(), data, config); memoryStream.Seek(0, SeekOrigin.Begin); diff --git a/IRaCIS.Core.Application/Service/Common/Export/TumorExportService.cs b/IRaCIS.Core.Application/Service/Common/Export/TumorExportService.cs index dd8ce3cd5..f08d03e6c 100644 --- a/IRaCIS.Core.Application/Service/Common/Export/TumorExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/Export/TumorExportService.cs @@ -601,18 +601,21 @@ public class Tumor_CDISC_ExportService(IRepository t.SubjectCode == task.SubjectCode && t.ARM_TumorNo == $"{task.ArmEnumStr}_{lesion.LessionCode}")) { - tu.BodyPart = _userInfo.IsEn_Us ? trialOrganDic[lesion.OrganInfoId.Value].PartEN : trialOrganDic[lesion.OrganInfoId.Value].Part; + var tu = CreatNewTUExport(task, lesion, visitIndexNoDic, translateDataList, isEn_Us); + + if (lesion.OrganInfoId.HasValue) + { + tu.BodyPart = _userInfo.IsEn_Us ? trialOrganDic[lesion.OrganInfoId.Value].PartEN : trialOrganDic[lesion.OrganInfoId.Value].Part; + } + + + Fill_Resisit_Lugano_TUExport(tu, lesion); + + tuList.Add(tu); } - - Fill_Resisit_Lugano_TUExport(tu, lesion); - - tuList.Add(tu); - #endregion