.net - How do I edit an existing table with EPPlus -
I have a template xlsx file with an Excel worksheet with a table. I am making the worksheet popular with EPplus how do I edit the table?
The problem in the answer given above works if it changes the number of columns and names / columns It has not happened, but if there has been a change in schema then it will fail. Set
- set
count to
table columns . Element:
The table header table Columns in your table with the column elements inside the Syncronise
column element
on table = sheet.Tables. First(); Var table element = table TablesXml.DocumentElement; Table element Attribute ["referee"]. Value = RNG Address; Var columnNode = tableElement ["tableColumns"]; ColumnNode.Attributes ["count"]. Value = rng.End.Column.ToString (); (Int i = 0; I & lt; dataTable.Columns.Count; i ++) {if (columnNode.ChildNodes.Count == i) {var clonedNode = columnNode.ChildNodes [i - 1] .CloneNode (true ); ClonedNode.Attributes ["id"]. Value = (i + 1). Ostring (); ClonedNode.Attributes ["name"]. Value = dataTable.Column [i] .ColumnName; ColumnNode.AppendChild (clonedNode); } And {columnNode.ChildNodes [i]. ["Name"] Features. Value = dataTable.Columns [i] .ColumnName; } If (i == reportInstance.Data.Columns.Count - 1) {while (columnNode.ChildNodes.Count> reportInstance.Data.Columns.Count) {columnNode.RemoveChild (columnNode.ChildNodes [i + 1]); }}} If (table element ["autofilter"] = null) {table element ["autofilter"]. Attribute ["referee"]. Value = rng.Address; }
Comments
Post a Comment