Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Change header of table

$
0
0
Hello, I am creating a workbook with a worksheet and a table. Afterwards I want to change the title of the header for each column. I have already tried different ways, but when I open the xmls file, excel shows an error message(after pressing repair file it opens). It seems like that other user had also the same problem, but not any these solutions have worked for me. Maybe someone can give me a hint. From my config, I am getting the new header text. Here my code:
var headerRows = myTable.HeadersRow();
for (var i = 1; i <= headerRows.CellCount(); i++)
{
       var newheaderText = config.Columns[i - 1].HeaderText;
       myTable.Field(headerRows.Cell(i).Value.ToString()).Name = newheaderText;
       headerRows.Cell(i).SetValue(newheaderText);
}
myWorkBook.SaveAs(stream);

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>