using MWS.Domain.Common.DataExporting.Excel.EpPlus;
using MWS.Domain.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MWS.Domain.Common.DataExporting
{
    public class WeightStatisticsExcelExporter: EpPlusExcelExporterBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="userListDtos"></param>
        public void ExportToFile(string filePath, List<ReportDto> reportDtoDtos, string[] headerList)
        {
            CreateExcelPackage(
              filePath,
              excelPackage =>
              {
                  var sheet = excelPackage.Workbook.Worksheets.Add("OperatorRecords");
                  sheet.OutLineApplyStyle = true;
                  AddHeader(sheet, headerList);
                  //AddHeader(
                  //    sheet,
                  //   "设备",
                  //   "料口",
                  //   "班组",
                  //   "重量",
                  //   "时间"
                  //    );

                  AddObjects(
                      sheet, 2, reportDtoDtos,
                      _ => _.Time,
                      _ => _.Count,
                      _ => _.NetWeight,
                      _ => _.Data1,
                      _ => _.Data2,
                      _ => _.Data3
                      );


                  //var lastLoginTimeColumn = sheet.Column(3);
                  //lastLoginTimeColumn.Style.Numberformat.Format = "yyyy-MM-dd HH:mm:ss";

                  //var creationTimeColumn = sheet.Column(4);
                  //creationTimeColumn.Style.Numberformat.Format = "yyyy-MM-dd HH:mm:ss";

                  for (var i = 1; i <= 6; i++)
                  {
                      sheet.Column(i).AutoFit();
                  }
              });
        }
    }
}
