Преглед изворни кода

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 Прегледај датотеку

return InsertRow(RowCount); 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> /// <summary>
/// Insert a column to the right of a Table. /// Insert a column to the right of a Table.
/// </summary> /// </summary>
return newRow; 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> /// <summary>
/// Insert a column into a table. /// Insert a column into a table.
/// </summary> /// </summary>

+ 2
- 0
Examples/Program.cs Прегледај датотеку

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

Loading…
Откажи
Сачувај