Compare commits
No commits in common. "aba7dfdec96bc3b2c4d98052eb672748d7083a8f" and "b8f5f32596feec51824d1416a154e6fd35631094" have entirely different histories.
aba7dfdec9
...
b8f5f32596
|
|
@ -8,9 +8,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using MiniExcelLibs;
|
using MiniExcelLibs;
|
||||||
using MiniExcelLibs.OpenXml;
|
using MiniExcelLibs.OpenXml;
|
||||||
using NPOI.HSSF.UserModel;
|
|
||||||
using NPOI.SS.Formula.Functions;
|
using NPOI.SS.Formula.Functions;
|
||||||
using NPOI.SS.UserModel;
|
|
||||||
using NPOI.XSSF.UserModel;
|
using NPOI.XSSF.UserModel;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
@ -394,44 +392,33 @@ public static class ExcelExportHelper
|
||||||
workbook.RemoveSheetAt(1);
|
workbook.RemoveSheetAt(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
ISheet sheet = workbook.GetSheetAt(0); // 获取第一个工作表
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < sheet.LastRowNum + 1; i++)
|
|
||||||
{
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var memoryStream2 = new MemoryStream();
|
var memoryStream2 = new MemoryStream();
|
||||||
workbook.Write(memoryStream2, true);
|
workbook.Write(memoryStream2, true);
|
||||||
|
|
||||||
memoryStream2.Seek(0, SeekOrigin.Begin);
|
memoryStream2.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
templateStream = memoryStream2;
|
templateStream = memoryStream2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 文件名称 从sheet里面取
|
||||||
|
//fileNmae = workbook.GetSheetName(0);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
return new FileStreamResult(templateStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
|
||||||
|
var config = new OpenXmlConfiguration()
|
||||||
|
{
|
||||||
|
IgnoreTemplateParameterMissing = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
await MiniExcel.SaveAsByTemplateAsync(memoryStream, templateStream.ToArray(), inDto.Data, config);
|
||||||
|
|
||||||
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
|
||||||
|
return new FileStreamResult(memoryStream, "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"
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -582,7 +582,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
|
|
||||||
var values = new TemplateData()
|
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,
|
TaskBlindName = taskinfo.TaskBlindName,
|
||||||
};
|
};
|
||||||
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
|
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 taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).FirstNotNullAsync();
|
||||||
var values = new TemplateData()
|
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,
|
TaskBlindName = taskinfo.TaskBlindName,
|
||||||
};
|
};
|
||||||
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
|
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 taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).FirstNotNullAsync();
|
||||||
var values = new TemplateData()
|
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,
|
TaskBlindName = taskinfo.TaskBlindName,
|
||||||
};
|
};
|
||||||
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
|
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using IRaCIS.Core.Application.Contracts;
|
using IRaCIS.Core.Application.Contracts;
|
||||||
using IRaCIS.Core.Application.Helper;
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using MiniExcelLibs.Attributes;
|
using MiniExcelLibs.Attributes;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue