forked from ddrilling/AsbCloudServer
IvanovEugeniy
e16df1f705
внесение корректировок в сервис DailyReport Убраны лишние комментарии и лишний код : -из классов создающих блоки отчета -из метода MakerExcel Добавлен блок Dimensionless
58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
using AsbCloudApp.Data;
|
|
using AsbCloudApp.Data.DailyReport;
|
|
using AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks;
|
|
using ClosedXML.Excel;
|
|
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace AsbCloudInfrastructure.Services.DailyReport
|
|
{
|
|
public class DailyReportMakerExcel
|
|
{
|
|
public Stream MakeReportFromBlocks(DailyReportDto dto)
|
|
{
|
|
using var workbook = new XLWorkbook();
|
|
FillExampleBlocks(workbook, dto);
|
|
MemoryStream memoryStream = new MemoryStream();
|
|
workbook.SaveAs(memoryStream, new SaveOptions { });
|
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
|
return memoryStream;
|
|
}
|
|
|
|
private void FillExampleBlocks(XLWorkbook workbook, DailyReportDto dto)
|
|
{
|
|
var sheet = workbook.Worksheets.Add(dto.HeadDto.ReportDate.ToString("dd.MM.yyyy"));
|
|
var addressStart = new CellAddress(sheet, 1, 1);
|
|
var blockHeader = new HeadBlock(addressStart, dto.HeadDto);
|
|
addressStart = blockHeader.AddressBlockEnd + (1, 0);
|
|
addressStart.ColumnNumber = 0;
|
|
var blockBha = new BhaBlock(addressStart, dto.BhaDto);
|
|
addressStart = blockBha.AddressBlockEnd + (1, 0);
|
|
addressStart.ColumnNumber = 0;
|
|
var timeBalance = new TimeBalanceBlock(addressStart, dto.TimeBalanceDto);
|
|
addressStart = timeBalance.AddressBlockEnd + (1, 0);
|
|
addressStart.ColumnNumber = 0;
|
|
var blockDimensionless = new DimensionlessBlock(addressStart, dto.DimensionlessDto);
|
|
addressStart = blockDimensionless.AddressBlockEnd + (1, 0);
|
|
addressStart.ColumnNumber = 0;
|
|
var blockSign = new SignBlock(addressStart, dto.SignDto);
|
|
addressStart = blockSign.AddressBlockEnd + (1, 0);
|
|
addressStart.ColumnNumber = 0;
|
|
|
|
|
|
blockHeader.Draw(sheet);
|
|
blockBha.Draw(sheet);
|
|
timeBalance.Draw(sheet);
|
|
blockDimensionless.Draw(sheet);
|
|
blockSign.Draw(sheet);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|