public void TestRender_DynamicPanel_In_DataSourcePanel_Vertical() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange parentRange = ws.Range(1, 2, 4, 2); parentRange.AddToNamed("ParentRange", XLScope.Worksheet); IXLRange childRange = ws.Range(2, 2, 4, 2); childRange.AddToNamed("ChildRange", XLScope.Worksheet); ws.Cell(1, 2).Value = "{di:Name}"; ws.Cell(2, 2).Value = "{Headers}"; ws.Cell(3, 2).Value = "{Data}"; ws.Cell(4, 2).Value = "{Totals}"; var parentPanel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("ParentRange"), report, report.TemplateProcessor); var childPanel = new ExcelDataSourceDynamicPanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange"), report, report.TemplateProcessor) { Parent = parentPanel, }; parentPanel.Children = new[] { childPanel }; parentPanel.Render(); Assert.AreEqual(ws.Range(1, 2, 12, 3), parentPanel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourceDynamicPanel_InsideDataSourcePanel_Test), nameof(TestRender_DynamicPanel_In_DataSourcePanel_Vertical)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestHorizontalInVerticalPanelsGrouping() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange parentRange = ws.Range(2, 2, 4, 3); parentRange.AddToNamed("ParentRange", XLScope.Worksheet); IXLRange child = ws.Range(2, 3, 4, 3); child.AddToNamed("ChildRange", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(3, 3).Value = "{di:Field1}"; ws.Cell(4, 3).Value = "{di:Field2}"; var parentPanel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("ParentRange"), report, report.TemplateProcessor); var childPanel = new ExcelDataSourcePanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange"), report, report.TemplateProcessor) { Parent = parentPanel, Type = PanelType.Horizontal, }; parentPanel.Children = new[] { childPanel }; parentPanel.Render(); Assert.AreEqual(ws.Range(2, 2, 10, 5), parentPanel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelRender_WithGrouping_MixedPanels_Test), nameof(TestHorizontalInVerticalPanelsGrouping)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestPanelRenderEvents() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(2, 2, 2, 3); range.AddToNamed("TestRange", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(2, 3).Value = "{di:Date}"; var panel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("TestRange"), report, report.TemplateProcessor) { BeforeRenderMethodName = "TestExcelDataSourcePanelBeforeRender", AfterRenderMethodName = "TestExcelDataSourcePanelAfterRender", BeforeDataItemRenderMethodName = "TestExcelDataItemPanelBeforeRender", AfterDataItemRenderMethodName = "TestExcelDataItemPanelAfterRender", }; panel.Render(); Assert.AreEqual(ws.Range(2, 2, 4, 2), panel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelIEnumerableRenderTest), nameof(TestPanelRenderEvents)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestRenderDataSet() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(2, 2, 2, 6); range.AddToNamed("TestRange", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Id}"; ws.Cell(2, 3).Value = "{di:Name}"; ws.Cell(2, 4).Value = "{di:IsVip}"; ws.Cell(2, 5).Value = "{di:Description}"; ws.Cell(2, 6).Value = "{di:Type}"; var panel = new ExcelDataSourcePanel("m:DataProvider:GetAllCustomersDataSet()", ws.NamedRange("TestRange"), report, report.TemplateProcessor); panel.Render(); Assert.AreEqual(ws.Range(2, 2, 4, 6), panel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelDataSetRenderTest), nameof(TestRenderDataSet)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestRenderEmptyDataSet() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(2, 2, 2, 6); range.AddToNamed("TestRange", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Id}"; ws.Cell(2, 3).Value = "{di:Name}"; ws.Cell(2, 4).Value = "{di:IsVip}"; ws.Cell(2, 5).Value = "{di:Description}"; ws.Cell(2, 6).Value = "{di:Type}"; var panel = new ExcelDataSourcePanel("m:DataProvider:GetEmptyDataSet()", ws.NamedRange("TestRange"), report, report.TemplateProcessor); panel.Render(); Assert.IsNull(panel.ResultRange); Assert.AreEqual(0, ws.CellsUsed(XLCellsUsedOptions.Contents).Count()); Assert.AreEqual(0, ws.NamedRanges.Count()); Assert.AreEqual(0, ws.Workbook.NamedRanges.Count()); Assert.AreEqual(1, ws.Workbook.Worksheets.Count); //report.Workbook.SaveAs("test.xlsx"); }
public void TestRenderIEnumerableVerticalNoShift() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(2, 2, 3, 5); range.AddToNamed("TestRange", XLScope.Worksheet); range.FirstCell().Style.Border.SetTopBorder(XLBorderStyleValues.Thin); range.FirstCell().Style.Border.SetBottomBorder(XLBorderStyleValues.Thin); range.FirstCell().Style.Border.SetLeftBorder(XLBorderStyleValues.Thin); ws.Cell(3, 5).Style.Border.SetBottomBorder(XLBorderStyleValues.Thin); ws.Cell(2, 4).DataType = XLDataType.Number; //ws.Cell(2, 4).DataType = XLCellValues.Number; ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(2, 3).Value = "{di:Date}"; ws.Cell(2, 4).Value = "{di:Sum}"; ws.Cell(2, 5).Value = "{di:Contacts}"; ws.Cell(3, 2).Value = "{di:Contacts.Phone}"; ws.Cell(3, 3).Value = "{di:Contacts.Fax}"; ws.Cell(3, 4).Value = "{p:StrParam}"; ws.Cell(1, 1).Value = "{di:Name}"; ws.Cell(4, 1).Value = "{di:Name}"; ws.Cell(1, 6).Value = "{di:Name}"; ws.Cell(4, 6).Value = "{di:Name}"; ws.Cell(3, 1).Value = "{di:Name}"; ws.Cell(3, 6).Value = "{di:Name}"; ws.Cell(1, 4).Value = "{di:Name}"; ws.Cell(4, 4).Value = "{di:Name}"; ws.Cell(8, 5).Value = "{di:Date}"; ws.Cell(8, 5).Style.Border.SetTopBorder(XLBorderStyleValues.Thin); ws.Cell(8, 5).Style.Border.SetRightBorder(XLBorderStyleValues.Thin); ws.Cell(8, 5).Style.Border.SetBottomBorder(XLBorderStyleValues.Thin); ws.Cell(8, 5).Style.Border.SetLeftBorder(XLBorderStyleValues.Thin); ws.Cell(8, 5).Style.Border.SetTopBorderColor(XLColor.Red); ws.Cell(8, 5).Style.Border.SetRightBorderColor(XLColor.Red); ws.Cell(8, 5).Style.Border.SetBottomBorderColor(XLColor.Red); ws.Cell(8, 5).Style.Border.SetLeftBorderColor(XLColor.Red); var panel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("TestRange"), report, report.TemplateProcessor) { ShiftType = ShiftType.NoShift, }; panel.Render(); Assert.AreEqual(ws.Range(2, 2, 7, 5), panel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelIEnumerableRenderTest), nameof(TestRenderIEnumerableVerticalNoShift)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void Test_HorizontalPanelsGrouping_ChildLeft_ParentRowShiftChildRowShift_WithFictitiousColumn() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange parentRange = ws.Range(2, 2, 5, 4); parentRange.AddToNamed("ParentRange", XLScope.Worksheet); IXLRange child = ws.Range(2, 3, 5, 3); child.AddToNamed("ChildRange", XLScope.Worksheet); child.Range(2, 1, 4, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; child.Range(2, 1, 4, 1).Style.Border.OutsideBorderColor = XLColor.Red; parentRange.Style.Border.OutsideBorder = XLBorderStyleValues.Thin; parentRange.Style.Border.OutsideBorderColor = XLColor.Black; ws.Cell(2, 4).Value = "{di:Name}"; ws.Cell(3, 4).Value = "{di:Date}"; ws.Cell(3, 3).Value = "{di:Field1}"; ws.Cell(4, 3).Value = "{di:Field2}"; ws.Cell(5, 3).Value = "{di:parent:Sum}"; ws.Cell(1, 1).Value = "{di:Name}"; ws.Cell(1, 3).Value = "{di:Name}"; ws.Cell(1, 5).Value = "{di:Name}"; ws.Cell(3, 1).Value = "{di:Name}"; ws.Cell(3, 5).Value = "{di:Name}"; ws.Cell(6, 1).Value = "{di:Name}"; ws.Cell(6, 3).Value = "{di:Name}"; ws.Cell(6, 5).Value = "{di:Name}"; var parentPanel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("ParentRange"), report, report.TemplateProcessor) { Type = PanelType.Horizontal, ShiftType = ShiftType.Row, }; var childPanel = new ExcelDataSourcePanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange"), report, report.TemplateProcessor) { Parent = parentPanel, Type = PanelType.Horizontal, ShiftType = ShiftType.Row, }; parentPanel.Children = new[] { childPanel }; parentPanel.Render(); Assert.AreEqual(ws.Range(2, 2, 5, 12), parentPanel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelRender_WithGrouping_HorizontalPanels_ChildLeft_Test), "ParentRowShiftChildRowShift_WithFictitiousColumn"), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void Test_VerticalPanelsGrouping_ChildTop_ParentNoShiftChildCellsShift_WithFictitiousRowWhichDeleteAfterRender() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange parentRange = ws.Range(2, 2, 4, 5); parentRange.AddToNamed("ParentRange", XLScope.Worksheet); IXLRange child = ws.Range(3, 2, 3, 5); child.AddToNamed("ChildRange", XLScope.Worksheet); child.Range(1, 2, 1, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; child.Range(1, 2, 1, 4).Style.Border.OutsideBorderColor = XLColor.Red; parentRange.Style.Border.OutsideBorder = XLBorderStyleValues.Thin; parentRange.Style.Border.OutsideBorderColor = XLColor.Black; ws.Cell(4, 2).Value = "{di:Name}"; ws.Cell(4, 3).Value = "{di:Date}"; ws.Cell(3, 3).Value = "{di:Field1}"; ws.Cell(3, 4).Value = "{di:Field2}"; ws.Cell(3, 5).Value = "{di:parent:Sum}"; ws.Cell(1, 1).Value = "{di:Name}"; ws.Cell(5, 1).Value = "{di:Name}"; ws.Cell(1, 6).Value = "{di:Name}"; ws.Cell(5, 6).Value = "{di:Name}"; ws.Cell(3, 1).Value = "{di:Name}"; ws.Cell(3, 6).Value = "{di:Name}"; ws.Cell(1, 4).Value = "{di:Name}"; ws.Cell(5, 4).Value = "{di:Name}"; var parentPanel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("ParentRange"), report, report.TemplateProcessor) { AfterDataItemRenderMethodName = "AfterRenderParentDataSourcePanelChildTop", ShiftType = ShiftType.NoShift, }; var childPanel = new ExcelDataSourcePanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange"), report, report.TemplateProcessor) { Parent = parentPanel, }; parentPanel.Children = new[] { childPanel }; parentPanel.Render(); Assert.AreEqual(ws.Range(2, 2, 9, 5), parentPanel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelRender_WithGrouping_VerticalPanels_ChildTop_Test), "ParentNoShiftChildCellsShift_WithFictitiousRowWhichDeleteAfterRender"), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void Test_VerticalPageBreaks_WithSimplePanel_RowShift() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange parentRange = ws.Range(2, 2, 5, 4); parentRange.AddToNamed("ParentRange", XLScope.Worksheet); parentRange.Style.Border.OutsideBorder = XLBorderStyleValues.Thin; IXLRange child1 = ws.Range(2, 3, 5, 3); child1.AddToNamed("ChildRange1", XLScope.Worksheet); IXLRange child2 = ws.Range(2, 4, 5, 4); child2.AddToNamed("ChildRange2", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(3, 2).Value = "{di:Date}"; ws.Cell(3, 3).Value = "{di:Field1}"; ws.Cell(4, 3).Value = "{di:Field2}"; ws.Cell(5, 3).Value = "{di:parent:Sum}"; ws.Cell(2, 4).Value = "{VertPageBreak}"; var parentPanel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("ParentRange"), report, report.TemplateProcessor) { Type = PanelType.Horizontal, ShiftType = ShiftType.Row, }; var childPanel1 = new ExcelDataSourcePanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange1"), report, report.TemplateProcessor) { Parent = parentPanel, Type = PanelType.Horizontal, ShiftType = ShiftType.Row, }; var childPanel2 = new ExcelNamedPanel(ws.NamedRange("ChildRange2"), report, report.TemplateProcessor) { Parent = parentPanel, }; parentPanel.Children = new[] { childPanel1, childPanel2 }; parentPanel.Render(); Assert.AreEqual(ws.Range(2, 2, 5, 12), parentPanel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelRender_WithGrouping_PageBreaks_Test), "Test_VerticalPageBreaks"), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void Test_TwoChildren_Horizontal() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange parentRange = ws.Range(2, 2, 5, 6); parentRange.AddToNamed("ParentRange", XLScope.Worksheet); IXLRange child1 = ws.Range(2, 4, 5, 4); child1.AddToNamed("ChildRange1", XLScope.Worksheet); IXLRange child2 = ws.Range(2, 6, 5, 6); child2.AddToNamed("ChildRange2", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(3, 3).Value = "Field1"; ws.Cell(3, 3).Style.Font.Bold = true; ws.Cell(4, 3).Value = "Field2"; ws.Cell(4, 3).Style.Font.Bold = true; ws.Cell(3, 4).Value = "{di:Field1}"; ws.Cell(4, 4).Value = "{di:Field2}"; ws.Cell(5, 5).Value = "Number"; ws.Cell(5, 5).Style.Font.Bold = true; ws.Cell(5, 6).Value = "{di:di}"; var parentPanel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("ParentRange"), report, report.TemplateProcessor); var childPanel1 = new ExcelDataSourcePanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange1"), report, report.TemplateProcessor) { Parent = parentPanel, Type = PanelType.Horizontal, }; var childPanel2 = new ExcelDataSourcePanel("di:ChildrenPrimitive", ws.NamedRange("ChildRange2"), report, report.TemplateProcessor) { Parent = parentPanel, Type = PanelType.Horizontal, }; parentPanel.Children = new[] { childPanel1, childPanel2 }; parentPanel.Render(); Assert.AreEqual(ws.Range(2, 2, 13, 8), parentPanel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelRender_WithGrouping_MultipleChildrenInOneParent), nameof(Test_TwoChildren_Horizontal)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestRenderDictionaryEnumerable() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range1 = ws.Range(2, 2, 2, 4); range1.AddToNamed("TestRange1", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(2, 3).Value = "{di:Value}"; ws.Cell(2, 4).Value = "{di:IsVip}"; var panel1 = new ExcelDataSourcePanel("m:DataProvider:GetDictionaryEnumerable()", ws.NamedRange("TestRange1"), report, report.TemplateProcessor); panel1.Render(); var dictWithDecimalValues = new List <IDictionary <string, decimal> > { new Dictionary <string, decimal> { ["Value"] = 25.7m }, new Dictionary <string, decimal> { ["Value"] = 250.7m }, new Dictionary <string, decimal> { ["Value"] = 2500.7m }, }; IXLRange range2 = ws.Range(2, 6, 2, 6); range2.AddToNamed("TestRange2", XLScope.Worksheet); ws.Cell(2, 6).Value = "{di:Value}"; var panel2 = new ExcelDataSourcePanel(dictWithDecimalValues, ws.NamedRange("TestRange2"), report, report.TemplateProcessor); panel2.Render(); Assert.AreEqual(ws.Range(2, 2, 4, 4), panel1.ResultRange); Assert.AreEqual(ws.Range(2, 6, 4, 6), panel2.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelDictionaryRenderTest), nameof(TestRenderDictionaryEnumerable)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestPanelRenderWithParentContext() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange parentRange = ws.Range(2, 2, 3, 5); parentRange.AddToNamed("ParentRange", XLScope.Worksheet); IXLRange child1 = ws.Range(2, 2, 2, 5); child1.AddToNamed("ChildRange1", XLScope.Worksheet); IXLRange child2 = ws.Range(3, 2, 3, 5); child2.AddToNamed("ChildRange2", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Field1}"; ws.Cell(2, 3).Value = "{di:Field2}"; ws.Cell(3, 2).Value = "{Count(di:Field1)}"; ws.Cell(3, 3).Value = "{Max(di:Field2)}"; ws.Cell(3, 4).Value = "{Max(di:parent:Sum)}"; ws.Cell(3, 5).Value = "{di:parent:Name}"; var parentPanel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("ParentRange"), report, report.TemplateProcessor); var childPanel1 = new ExcelDataSourcePanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange1"), report, report.TemplateProcessor) { Parent = parentPanel, }; var childPanel2 = new ExcelTotalsPanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange2"), report, report.TemplateProcessor) { Parent = parentPanel }; parentPanel.Children = new[] { childPanel1, childPanel2 }; parentPanel.Render(); Assert.AreEqual(ws.Range(2, 2, 9, 5), parentPanel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(TotalsPanelRenderTest), nameof(TestPanelRenderWithParentContext)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestRenderDictionary() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range1 = ws.Range(2, 2, 2, 3); range1.AddToNamed("TestRange", XLScope.Worksheet); IXLRange range2 = ws.Range(2, 5, 2, 6); range2.AddToNamed("TestRange2", XLScope.Worksheet); ws.Cell(1, 2).Value = "Key"; ws.Cell(1, 3).Value = "Value"; ws.Cell(2, 2).Value = "{di:Key}"; ws.Cell(2, 3).Value = "{di:Value}"; ws.Cell(1, 5).Value = "Key"; ws.Cell(1, 6).Value = "Value"; ws.Cell(2, 5).Value = "{di:Key}"; ws.Cell(2, 6).Value = "{di:Value}"; IDictionary <string, object> data1 = new DataProvider().GetDictionaryEnumerable().First(); var panel1 = new ExcelDataSourcePanel(data1, ws.NamedRange("TestRange"), report, report.TemplateProcessor); panel1.Render(); IEnumerable <KeyValuePair <string, object> > data2 = new DataProvider().GetDictionaryEnumerable().First() .Select(x => new KeyValuePair <string, object>(x.Key, x.Value)); var panel2 = new ExcelDataSourcePanel(data2, ws.NamedRange("TestRange2"), report, report.TemplateProcessor); panel2.Render(); Assert.AreEqual(ws.Range(2, 2, 4, 3), panel1.ResultRange); Assert.AreEqual(ws.Range(2, 5, 4, 6), panel2.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelDictionaryRenderTest), nameof(TestRenderDictionary)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestRenderIEnumerableOfString() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(2, 2, 2, 2); range.AddToNamed("TestRange", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:di}"; var panel = new ExcelDataSourcePanel(new[] { "One", "Two", "Three", "Four" }, ws.NamedRange("TestRange"), report, report.TemplateProcessor); panel.Render(); Assert.AreEqual(ws.Range(2, 2, 5, 2), panel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelIEnumerableRenderTest), nameof(TestRenderIEnumerableOfString)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
public void TestRenderNullItemHorizontalNoShift() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(2, 2, 3, 5); range.AddToNamed("TestRange", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(2, 3).Value = "{di:Date}"; ws.Cell(2, 4).Value = "{m:Multiply(di:Sum, 5)}"; ws.Cell(2, 5).Value = "{di:Contacts}"; ws.Cell(3, 2).Value = "{di:Contacts.Phone}"; ws.Cell(3, 3).Value = "{di:Contacts.Fax}"; ws.Cell(3, 4).Value = "{p:StrParam}"; ws.Cell(1, 1).Value = "{di:Name}"; ws.Cell(4, 1).Value = "{di:Name}"; ws.Cell(1, 6).Value = "{di:Name}"; ws.Cell(4, 6).Value = "{di:Name}"; ws.Cell(3, 1).Value = "{di:Name}"; ws.Cell(3, 6).Value = "{di:Name}"; ws.Cell(1, 4).Value = "{di:Name}"; ws.Cell(4, 4).Value = "{di:Name}"; var panel = new ExcelDataSourcePanel("m:DataProvider:GetNullItem()", ws.NamedRange("TestRange"), report, report.TemplateProcessor) { Type = PanelType.Horizontal, ShiftType = ShiftType.NoShift, }; panel.Render(); Assert.IsNull(panel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelNullItemRenderTest), nameof(TestRenderNullItemHorizontalNoShift)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
// Rendering speed test //[Test] public void TestPanelRenderSpeed() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(2, 2, 2, 6); range.AddToNamed("TestRange", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(2, 3).Value = "{di:Date}"; ws.Cell(2, 4).Value = "{di:Sum}"; ws.Cell(2, 5).Value = "{di:Contacts.Phone}"; ws.Cell(2, 6).Value = "{di:Contacts.Fax}"; const int dataCount = 6000; IList <TestItem> data = new List <TestItem>(dataCount); for (int i = 0; i < dataCount; i++) { data.Add(new TestItem($"Name_{i}", DateTime.Now.AddHours(1), i + 10, new Contacts($"Phone_{i}", $"Fax_{i}"))); } var panel = new ExcelDataSourcePanel(data, ws.NamedRange("TestRange"), report, report.TemplateProcessor) { //ShiftType = ShiftType.Row, //ShiftType = ShiftType.NoShift, }; Stopwatch sw = Stopwatch.StartNew(); panel.Render(); sw.Stop(); //Stopwatch sw2 = Stopwatch.StartNew(); //report.Workbook.SaveAs("test.xlsx"); //sw2.Stop(); }
public void TestExpandDataPanel_ChildNotAcrossWidth_ChildBottom_RowShift() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange parentRange = ws.Range(2, 2, 3, 5); parentRange.AddToNamed("ParentRange", XLScope.Worksheet); parentRange.Style.Border.OutsideBorder = XLBorderStyleValues.Thin; parentRange.Style.Border.OutsideBorderColor = XLColor.Black; IXLRange childRange = ws.Range(3, 3, 3, 5); childRange.AddToNamed("ChildRange", XLScope.Worksheet); childRange.Style.Border.OutsideBorder = XLBorderStyleValues.Dashed; childRange.Style.Border.OutsideBorderColor = XLColor.Blue; ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(3, 3).Value = "{di:Field1}"; ws.Cell(3, 4).Value = "{di:Field2}"; var parentPanel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("ParentRange"), report, report.TemplateProcessor); var childPanel = new ExcelDataSourcePanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange"), report, report.TemplateProcessor) { Parent = parentPanel, ShiftType = ShiftType.Row, }; parentPanel.Children = new[] { childPanel }; parentPanel.Render(); Assert.AreEqual(ws.Range(2, 2, 9, 5), parentPanel.ResultRange); //report.Workbook.SaveAs("test.xlsx"); }
public void TestCancelPanelRender() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(2, 2, 2, 2); range.AddToNamed("TestRange", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:di}"; var panel = new ExcelDataSourcePanel(new[] { 1, 2, 3, 4 }, ws.NamedRange("TestRange"), report, report.TemplateProcessor) { BeforeRenderMethodName = "CancelPanelRender", }; panel.Render(); Assert.AreEqual(range, panel.ResultRange); Assert.AreEqual(1, ws.CellsUsed(XLCellsUsedOptions.Contents).Count()); Assert.AreEqual("{di:di}", ws.Cell(2, 2).Value); //report.Workbook.SaveAs("test.xlsx"); }
public void TestMultipleHorizontalPanelsGrouping() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange parentRange = ws.Range(2, 2, 7, 6); parentRange.AddToNamed("ParentRange", XLScope.Worksheet); IXLRange simpleRange1 = ws.Range(3, 3, 4, 3); simpleRange1.AddToNamed("simpleRange1"); IXLRange child = ws.Range(2, 4, 7, 6); child.AddToNamed("ChildRange", XLScope.Worksheet); IXLRange childOfChild = ws.Range(2, 5, 7, 6); childOfChild.AddToNamed("ChildOfChildRange"); IXLRange simpleRange2 = ws.Range(5, 6, 7, 6); simpleRange2.AddToNamed("simpleRange2", XLScope.Worksheet); simpleRange2.Style.Border.OutsideBorder = XLBorderStyleValues.Thin; simpleRange2.Style.Border.OutsideBorderColor = XLColor.Orange; childOfChild.Range(3, 1, 6, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; childOfChild.Range(3, 1, 6, 2).Style.Border.OutsideBorderColor = XLColor.Green; child.Range(2, 1, 6, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; child.Range(2, 1, 6, 3).Style.Border.OutsideBorderColor = XLColor.Red; simpleRange1.Style.Border.OutsideBorder = XLBorderStyleValues.Thin; simpleRange1.Style.Border.OutsideBorderColor = XLColor.Brown; parentRange.Style.Border.OutsideBorder = XLBorderStyleValues.Thin; parentRange.Style.Border.OutsideBorderColor = XLColor.Black; ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(3, 2).Value = "{di:Date}"; ws.Cell(3, 3).Value = "{p:StrParam}"; ws.Cell(4, 3).Value = "{di:Sum}"; ws.Cell(5, 3).Value = "{p:IntParam}"; ws.Cell(3, 4).Value = "{di:Field1}"; ws.Cell(4, 4).Value = "{di:Field2}"; ws.Cell(5, 4).Value = "{di:parent:Sum}"; ws.Cell(6, 4).Value = "{di:parent:Contacts}"; ws.Cell(4, 5).Value = "{di:Field1}"; ws.Cell(5, 5).Value = "{di:Field2}"; ws.Cell(6, 5).Value = "{di:parent:Field1}"; ws.Cell(7, 5).Value = "{di:parent:parent:Contacts.Phone}"; ws.Cell(5, 6).Value = "{p:DateParam}"; ws.Cell(6, 6).Value = "{di:parent:Field2}"; ws.Cell(7, 6).Value = "{di:parent:parent:Contacts.Fax}"; var parentPanel = new ExcelDataSourcePanel("m:DataProvider:GetIEnumerable()", ws.NamedRange("ParentRange"), report, report.TemplateProcessor) { Type = PanelType.Horizontal, }; var simplePanel1 = new ExcelNamedPanel(ws.Workbook.NamedRange("simpleRange1"), report, report.TemplateProcessor) { Parent = parentPanel, }; var childPanel = new ExcelDataSourcePanel("m:DataProvider:GetChildIEnumerable(di:Name)", ws.NamedRange("ChildRange"), report, report.TemplateProcessor) { Parent = parentPanel, Type = PanelType.Horizontal, }; var childOfChildPanel = new ExcelDataSourcePanel("di:Children", ws.Workbook.NamedRange("ChildOfChildRange"), report, report.TemplateProcessor) { Parent = childPanel, Type = PanelType.Horizontal, }; var simplePanel2 = new ExcelNamedPanel(ws.NamedRange("simpleRange2"), report, report.TemplateProcessor) { Parent = childOfChildPanel, }; childOfChildPanel.Children = new[] { simplePanel2 }; childPanel.Children = new[] { childOfChildPanel }; parentPanel.Children = new[] { childPanel, simplePanel1 }; parentPanel.Render(); Assert.AreEqual(ws.Range(2, 2, 7, 20), parentPanel.ResultRange); ExcelAssert.AreWorkbooksContentEquals(TestHelper.GetExpectedWorkbook(nameof(DataSourcePanelRender_WithGrouping_MixedPanels_Test), nameof(TestMultipleHorizontalPanelsGrouping)), ws.Workbook); //report.Workbook.SaveAs("test.xlsx"); }
// Rendering speed test //[Test] public void TestPanelRenderSpeedWithMultiHierarchy() { var report = new TestReport(); IXLWorksheet ws = report.Workbook.AddWorksheet("Test"); IXLRange range = ws.Range(2, 2, 4, 6); range.AddToNamed("ParentRange", XLScope.Worksheet); ws.Cell(2, 2).Value = "{di:Name}"; ws.Cell(2, 3).Value = "{di:Date}"; ws.Cell(2, 4).Value = "{di:Sum}"; ws.Cell(2, 5).Value = "{di:Contacts.Phone}"; ws.Cell(2, 6).Value = "{di:Contacts.Fax}"; IXLRange child1 = ws.Range(3, 2, 4, 6); child1.AddToNamed("ChildRange1", XLScope.Worksheet); ws.Cell(3, 2).Value = "{di:Field1}"; ws.Cell(3, 3).Value = "{di:Field2}"; IXLRange child2 = ws.Range(4, 2, 4, 6); child2.AddToNamed("ChildRange2", XLScope.Worksheet); ws.Cell(4, 5).Value = "{di:Field1}"; ws.Cell(4, 6).Value = "{di:Field2}"; const int dataCount = 50; IList <TestItem> data = new List <TestItem>(dataCount); for (int i = 0; i < dataCount; i++) { data.Add(new TestItem($"Name_{i}", DateTime.Now.AddHours(1), i + 1, new Contacts($"Phone_{i}", $"Fax_{i}"))); } var parentPanel = new ExcelDataSourcePanel(data, ws.NamedRange("ParentRange"), report, report.TemplateProcessor) { //ShiftType = ShiftType.Row, //ShiftType = ShiftType.NoShift, }; var childPanel1 = new ExcelDataSourcePanel("m:DataProvider:GetChildrenRandom(4, 6)", ws.NamedRange("ChildRange1"), report, report.TemplateProcessor) { //ShiftType = ShiftType.Row, //ShiftType = ShiftType.NoShift, Parent = parentPanel, }; var childPanel2 = new ExcelDataSourcePanel("m:DataProvider:GetChildrenRandom(10, 15)", ws.NamedRange("ChildRange2"), report, report.TemplateProcessor) { //ShiftType = ShiftType.Row, //ShiftType = ShiftType.NoShift, Parent = childPanel1, }; parentPanel.Children.Add(childPanel1); childPanel1.Children.Add(childPanel2); Stopwatch sw = Stopwatch.StartNew(); parentPanel.Render(); sw.Stop(); //Stopwatch sw2 = Stopwatch.StartNew(); //report.Workbook.SaveAs("test.xlsx"); //sw2.Stop(); }