Commit 77817fb2 by lcx

关闭筛选功能

parent 38e7014a
......@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>3af57781-f816-4c0e-ab66-9b69387e7d35</UserSecretsId>
</PropertyGroup>
<ItemGroup>
......
......@@ -14,6 +14,8 @@
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>a7ae6d0f-7b11-4eef-9fea-a279001ea54d</ProjectGuid>
<publishUrl>bin\Release\netcoreapp2.2\publish\</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<DeleteExistingFiles>True</DeleteExistingFiles>
<TargetFramework>netcoreapp2.2</TargetFramework>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
\ No newline at end of file
......@@ -314,6 +314,8 @@ public void Generate(per_allot allot, string mail)
logManageService.WriteMsg("绩效开始执行", $"数据来源:用户上传的Excel。", 1, allot.ID, "ReceiveMessage", true);
configService.Clear(allot.ID);
// 关闭筛选功能
ExtractHelper.CloseAutoFilter(allot.Path);
// 导出数据
excel = importDataService.ReadDataAndSave(allot);
......
using NPOI.SS.UserModel;
using OfficeOpenXml;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
......@@ -17,6 +18,7 @@ public static string GetExtractFile(int hospitalId, ref string newFilePath, stri
string originalPath = string.IsNullOrEmpty(allotFilePath)
? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "医院绩效模板.xls")
: allotFilePath;
CloseAutoFilter(originalPath);
var (tempPath, filePath) = CopyOriginalFile(hospitalId, originalPath);
newFilePath = filePath;
return tempPath;
......@@ -108,5 +110,30 @@ public static void ClearSheetPartialData(ISheet sheet, PerSheetPoint point, Shee
}
}
}
public static void CloseAutoFilter(string path)
{
try
{
var fileInfo = new FileInfo(path);
using (ExcelPackage package = new ExcelPackage(fileInfo))
{
ExcelWorkbook workbook = package.Workbook;
if (workbook == null) return;
foreach (var sheet in workbook.Worksheets)
{
if (sheet.AutoFilterAddress != null)
{
sheet.Cells[sheet.AutoFilterAddress.Address].AutoFilter = false;
}
}
package.Save();
}
}
catch (Exception ex)
{
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment