Merge branch 'Test_IRC_Net8' of http://192.168.3.68:2000/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
416a94e302
|
@ -8,7 +8,9 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Microsoft.Extensions.Hosting;
|
||||
using MiniExcelLibs;
|
||||
using MiniExcelLibs.OpenXml;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
|
@ -392,33 +394,44 @@ public static class ExcelExportHelper
|
|||
workbook.RemoveSheetAt(1);
|
||||
}
|
||||
|
||||
var memoryStream2 = new MemoryStream();
|
||||
workbook.Write(memoryStream2, true);
|
||||
|
||||
memoryStream2.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
templateStream = memoryStream2;
|
||||
|
||||
}
|
||||
|
||||
// 文件名称 从sheet里面取
|
||||
//fileNmae = workbook.GetSheetName(0);
|
||||
#endregion
|
||||
|
||||
|
||||
ISheet sheet = workbook.GetSheetAt(0); // 获取第一个工作表
|
||||
|
||||
var memoryStream = new MemoryStream();
|
||||
|
||||
|
||||
var config = new OpenXmlConfiguration()
|
||||
for (int i = 0; i < sheet.LastRowNum + 1; i++)
|
||||
{
|
||||
IgnoreTemplateParameterMissing = true,
|
||||
};
|
||||
|
||||
await MiniExcel.SaveAsByTemplateAsync(memoryStream, templateStream.ToArray(), inDto.Data, config);
|
||||
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
IRow row = sheet.GetRow(i);
|
||||
for (int j = 0; j < sheet.LastRowNum; j++)
|
||||
{
|
||||
ICell cell = row.GetCell(j);
|
||||
foreach (var property in inDto.Data.GetType().GetProperties())
|
||||
{
|
||||
var value = property.GetValue(inDto.Data);
|
||||
if (cell!=null&&cell.ToString() == "{{" + property.Name + "}}")
|
||||
{
|
||||
sheet.GetRow(i).GetCell(j).SetCellValue(value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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"
|
||||
};
|
||||
|
|
|
@ -582,7 +582,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
|
||||
var values = new TemplateData()
|
||||
{
|
||||
SubjectID = "'" + (taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode),
|
||||
SubjectID = (taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode),
|
||||
TaskBlindName = taskinfo.TaskBlindName,
|
||||
};
|
||||
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
|
||||
|
|
|
@ -449,7 +449,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).FirstNotNullAsync();
|
||||
var values = new TemplateData()
|
||||
{
|
||||
SubjectID = "'" + (taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode),
|
||||
SubjectID = (taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode),
|
||||
TaskBlindName = taskinfo.TaskBlindName,
|
||||
};
|
||||
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
|
||||
|
@ -626,7 +626,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).FirstNotNullAsync();
|
||||
var values = new TemplateData()
|
||||
{
|
||||
SubjectID = "'" + (taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode),
|
||||
SubjectID = (taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode),
|
||||
TaskBlindName = taskinfo.TaskBlindName,
|
||||
};
|
||||
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using MiniExcelLibs.Attributes;
|
||||
|
@ -146,7 +147,7 @@ namespace IRaCIS.Application.Contracts
|
|||
/// <summary>
|
||||
/// 数据
|
||||
/// </summary>
|
||||
public object Data { get; set; }
|
||||
public object Data { get; set; }
|
||||
}
|
||||
|
||||
public class ExportTemplateServiceDto : ExportTemplateAsyncDto
|
||||
|
|
Loading…
Reference in New Issue