Преглед на файлове

Fixed the problem with setting the column width.

Fixed the problem with setting the column width for the whole table.
Without this patch the SetColumnWidth method throws the
NullReferenceException if the column widths haven't been initialized
before. Added the test to check the issue and to see whether it's fixed.
master
vzhikserg преди 10 години
родител
ревизия
633d02a8b7
променени са 2 файла, в които са добавени 17 реда и са изтрити 2 реда
  1. 1
    1
      DocX/Table.cs
  2. 16
    1
      UnitTests/DocXUnitTests.cs

+ 1
- 1
DocX/Table.cs Целия файл

@@ -274,7 +274,7 @@ namespace Novacode
if (grid == null)
{
XElement tblPr = GetOrCreate_tblPr();
tblPr.AddAfterSelf(XName.Get("tblGrid", DocX.w.NamespaceName));
tblPr.AddAfterSelf(new XElement(XName.Get("tblGrid", DocX.w.NamespaceName)));
grid = Xml.Element(XName.Get("tblGrid", DocX.w.NamespaceName));
}

+ 16
- 1
UnitTests/DocXUnitTests.cs Целия файл

@@ -2731,7 +2731,22 @@ namespace UnitTests
Assert.AreEqual(bookmarkNames[i], result[i]);
}
}
}
}
[TestMethod]
public void CreateTable_WhenCalledSetColumnWidth_ReturnsExpected()
{
using (var document = DocX.Create("Set column width.docx"))
{
var table = document.InsertTable(1, 2);
table.SetColumnWidth(0, 1000);
table.SetColumnWidth(1, 2000);
Assert.AreEqual(1000, table.GetColumnWidth(0));
Assert.AreEqual(2000, table.GetColumnWidth(1));
}
}
}
}

Loading…
Отказ
Запис