瀏覽代碼

Added Table.InsertRow(Row row) and Table.InsertRow(Row row, Int32 index) methods. These methods insert a copy of original row into the table.

master
DragonFire_cp 14 年之前
父節點
當前提交
5d9fa34e5e
共有 2 個檔案被更改,包括 40 行新增0 行删除
  1. 38
    0
      DocX/Table.cs
  2. 2
    0
      Examples/Program.cs

+ 38
- 0
DocX/Table.cs 查看文件

@@ -595,6 +595,15 @@ namespace Novacode
return InsertRow(RowCount);
}
/// <summary>
/// Insert a copy of a row at the end of this table.
/// </summary>
/// <returns>A new row.</returns>
public Row InsertRow(Row row)
{
return InsertRow(row, RowCount);
}
/// <summary>
/// Insert a column to the right of a Table.
/// </summary>
@@ -807,6 +816,35 @@ namespace Novacode
return newRow;
}
/// <summary>
/// Insert a copy of a row into this table.
/// </summary>
/// <param name="row">Row to copy and insert.</param>
/// <param name="index">Index to insert row at.</param>
/// <returns>A new Row</returns>
public Row InsertRow(Row row, int index)
{
if (index < 0 || index > RowCount)
throw new IndexOutOfRangeException();
Row newRow = new Row(this, Document, row.Xml);
XElement rowXml;
if (index == Rows.Count)
{
rowXml = Rows.Last().Xml;
rowXml.AddAfterSelf(newRow.Xml);
}
else
{
rowXml = Rows[index].Xml;
rowXml.AddBeforeSelf(newRow.Xml);
}
return newRow;
}
/// <summary>
/// Insert a column into a table.
/// </summary>

+ 2
- 0
Examples/Program.cs 查看文件

@@ -274,6 +274,8 @@ namespace Examples
table.Rows[1].Cells[0].Paragraphs[0].Append("4");
table.Rows[1].Cells[1].Paragraphs[0].Append("1");
table.InsertRow(table.Rows[1]);
// Add an image into the document.
Novacode.Image image = document.AddImage(@"images\logo_template.png");

Loading…
取消
儲存