diff --git a/ClosedXML_Tests/Excel/Tables/TablesTests.cs b/ClosedXML_Tests/Excel/Tables/TablesTests.cs index 7ebf9bc..7ccce95 100644 --- a/ClosedXML_Tests/Excel/Tables/TablesTests.cs +++ b/ClosedXML_Tests/Excel/Tables/TablesTests.cs @@ -1,10 +1,10 @@ -using System; +using ClosedXML.Excel; +using NUnit.Framework; +using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; -using ClosedXML.Excel; -using NUnit.Framework; namespace ClosedXML_Tests.Excel { @@ -24,8 +24,8 @@ public void CanSaveTableCreatedFromEmptyDataTable() { var dt = new DataTable("sheet1"); - dt.Columns.Add("col1", typeof (string)); - dt.Columns.Add("col2", typeof (double)); + dt.Columns.Add("col1", typeof(string)); + dt.Columns.Add("col2", typeof(double)); var wb = new XLWorkbook(); wb.AddWorksheet(dt); @@ -128,8 +128,8 @@ public void TableCreatedFromEmptyDataTable() { var dt = new DataTable("sheet1"); - dt.Columns.Add("col1", typeof (string)); - dt.Columns.Add("col2", typeof (double)); + dt.Columns.Add("col1", typeof(string)); + dt.Columns.Add("col2", typeof(double)); var wb = new XLWorkbook(); IXLWorksheet ws = wb.AddWorksheet("Sheet1"); @@ -177,13 +177,9 @@ row = table.DataRange.InsertRowsAbove(1).First(); row.Field("Value").Value = 1; - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox.xlsx"); - Assert.AreEqual(1, ws.Cell(2, 1).GetDouble()); Assert.AreEqual(2, ws.Cell(3, 1).GetDouble()); Assert.AreEqual(3, ws.Cell(4, 1).GetDouble()); - - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox.xlsx"); } [Test] @@ -196,20 +192,17 @@ IXLTable table = ws.Range("A1:A2").CreateTable(); table.SetShowTotalsRow() .Field(0).TotalsRowFunction = XLTotalsRowFunction.Sum; - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox1.xlsx"); + IXLTableRow row = table.DataRange.FirstRow(); row.Field("Value").Value = 3; row = row.InsertRowsAbove(1).First(); row.Field("Value").Value = 2; row = row.InsertRowsAbove(1).First(); row.Field("Value").Value = 1; - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox2.xlsx"); Assert.AreEqual(1, ws.Cell(2, 1).GetDouble()); Assert.AreEqual(2, ws.Cell(3, 1).GetDouble()); Assert.AreEqual(3, ws.Cell(4, 1).GetDouble()); - - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox.xlsx"); } [Test] @@ -230,8 +223,6 @@ row = table.DataRange.InsertRowsBelow(1).First(); row.Field("Value").Value = 3; - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox.xlsx"); - Assert.AreEqual(1, ws.Cell(2, 1).GetDouble()); Assert.AreEqual(2, ws.Cell(3, 1).GetDouble()); Assert.AreEqual(3, ws.Cell(4, 1).GetDouble()); @@ -258,8 +249,6 @@ Assert.AreEqual(1, ws.Cell(2, 1).GetDouble()); Assert.AreEqual(2, ws.Cell(3, 1).GetDouble()); Assert.AreEqual(3, ws.Cell(4, 1).GetDouble()); - - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox.xlsx"); } [Test] @@ -272,11 +261,13 @@ .CellBelow().SetValue("B") .CellBelow().SetValue("C"); - ws.RangeUsed().CreateTable().SetShowHeaderRow(false); + IXLTable table = ws.RangeUsed().CreateTable(); - IXLTable table = ws.Tables.First(); + Assert.AreEqual("Categories", table.Fields.First().Name); - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox1.xlsx"); + table.SetShowHeaderRow(false); + + Assert.AreEqual("Categories", table.Fields.First().Name); Assert.IsTrue(ws.Cell(1, 1).IsEmpty(true)); Assert.AreEqual(null, table.HeadersRow()); @@ -290,15 +281,11 @@ Assert.AreNotEqual(null, headerRow); Assert.AreEqual("Categories", headerRow.Cell(1).GetString()); - table.SetShowHeaderRow(false); ws.FirstCell().SetValue("x"); table.SetShowHeaderRow(); - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox2.xlsx"); - - //wb.SaveAs(@"D:\Excel Files\ForTesting\Sandbox3.xlsx"); Assert.AreEqual("x", ws.FirstCell().GetString()); Assert.AreEqual("Categories", ws.Cell("A2").GetString()); @@ -333,4 +320,4 @@ Assert.AreEqual("LastName", cellValue); } } -} \ No newline at end of file +}