public void ToExcel_DefaultSettings_ShouldExport() { IEnumerableToExcelExporter <Customer> exporter = new OpenOfficeEnumerableToExcelExporter <Customer>(); List <Customer> customers = new List <Customer>() { new Customer() { Name = "Beverley Wyndhame", Address = "1830 Metz Lane, Pennsville, New Jersey, USA", Email = "*****@*****.**" }, new Customer() { Name = "Brighton Buckley", Address = "Lodorp 3113, Maffe, Namur, Belgium", Email = "*****@*****.**" } }; MemoryStream memoryStream = exporter.ToExcel(customers); Assert.IsTrue(memoryStream.Length == 2982); }
public void ToExcel_CustomSettings_ShouldExport() { IEnumerableToExcelExporter <Customer> exporter = new OpenOfficeEnumerableToExcelExporter <Customer>( new ExcelSettings() { BackgroundColor = System.Drawing.Color.GreenYellow, Color = System.Drawing.Color.Black, SheetName = "Customers" }); List <Customer> customers = new List <Customer>() { new Customer() { Name = "Beverley Wyndhame", Address = "1830 Metz Lane, Pennsville, New Jersey, USA", Email = "*****@*****.**" }, new Customer() { Name = "Brighton Buckley", Address = "Lodorp 3113, Maffe, Namur, Belgium", Email = "*****@*****.**" } }; MemoryStream memoryStream = exporter.ToExcel(customers); Assert.IsTrue(memoryStream.Length == 3000); }
public void ExportToExcel() { List <Customer> customers = new List <Customer>() { new Customer() { Name = "Beverley Wyndhame", Address = "1830 Metz Lane, Pennsville, New Jersey, USA", Email = "*****@*****.**" }, new Customer() { Name = "Brighton Buckley", Address = "Lodorp 3113, Maffe, Namur, Belgium", Email = "*****@*****.**" } }; IEnumerableToExcelExporter <Customer> exporter = new OpenOfficeEnumerableToExcelExporter <Customer>(); HttpRequestMessage request = new HttpRequestMessage(); HttpResponseMessage response = request.ExportToExcel(customers, exporter); Assert.IsTrue(response.Content.Headers.ContentLength == 2982); }