public void TestPanelWithNoData() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(1, 1, 1, 5); range.AddToNamed("Test", XLScope.Worksheet); ws.Cell(1, 1).Value = "Plain text"; ws.Cell(1, 2).Value = "{Sum(di:Sum)}"; ws.Cell(1, 3).Value = "{ Custom(DI:Sum, CustomAggregation, PostAggregation) }"; ws.Cell(1, 4).Value = "{Min(di:Sum)}"; ws.Cell(1, 5).Value = "Text1 {count(di:Name)} Text2 {avg(di:Sum, , PostAggregationRound)} Text3 {Max(di:Sum)}"; var panel = new ExcelTotalsPanel("m:DataProvider:GetEmptyIEnumerable()", ws.NamedRange("Test"), report, report.TemplateProcessor); panel.Render(); Assert.AreEqual(range, panel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(TotalsPanelRenderTest), nameof(TestPanelWithNoData)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestPanelRender() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(1, 1, 1, 12); range.AddToNamed("Test", XLScope.Worksheet); ws.Cell(1, 1).Value = "Plain text"; ws.Cell(1, 2).Value = "{Sum(di:Sum)}"; ws.Cell(1, 3).Value = "{ Custom(DI:Sum, CustomAggregation, PostAggregation) }"; ws.Cell(1, 4).Value = "{Min(di:Sum)}"; ws.Cell(1, 5).Value = "Text1 {count(di:Name)} Text2 {avg(di:Sum, , PostAggregationRound)} {p:StrParam} {Max(di:Sum)} {Max(di:Sum)}"; ws.Cell(1, 6).Value = "{Mix(di:Sum)}"; ws.Cell(1, 7).FormulaA1 = "=SUM(B1:D1)"; ws.Cell(1, 8).FormulaA1 = "=ROW()"; ws.Cell(1, 9).Value = "{sf:Format(p:DateParam, yyyyMMdd)}"; ws.Cell(1, 10).Value = "{p:IntParam}"; ws.Cell(1, 11).Value = "{sf:Format(m:TestClassForTotals:Round(Min(di:Sum), 1), #,,0.0000)}"; ws.Cell(1, 12).Value = "Aggregation: {m:TestClassForTotals:Meth(avg(di:Sum, , PostAggregationRound), Max( di : Sum ))}. Date: {sf:Format(p:DateParam, dd.MM.yyyy)}"; ws.Cell(1, 13).Value = "{Sum(di:Sum)}"; var panel = new ExcelTotalsPanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("Test"), report, report.TemplateProcessor) { BeforeRenderMethodName = "TestExcelTotalsPanelBeforeRender", AfterRenderMethodName = "TestExcelTotalsPanelAfterRender", }; panel.Render(); Assert.AreEqual(range, panel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(TotalsPanelRenderTest), nameof(TestPanelRender)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }