This project has moved. For the latest updates, please go here.

Change header of table

Oct 6, 2014 at 1:44 PM
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;
Oct 6, 2014 at 8:50 PM
It was a bug. Pick up the latest source code.

Oct 8, 2014 at 1:30 PM
Thank you very much for your answer. Unfortunately, it still does not work. I have illustrated an example:
 public class Test
           public string Test1 { get; set; }
           public string Test2 { get; set; }

public void MyTest()
            List<Test> testList = new List<Test>
                new Test{Test1 = "T1",Test2 = "T2"},
                new Test{Test1 = "T1",Test2 = "T2"}

            var wb1 = new XLWorkbook();
            var ws = wb1.Worksheets.Add("Mysheet");
            ws.Cell(1, 1).InsertTable(testList);

            var wb2 = new XLWorkbook();
            var ws2 = wb2.Worksheets.Add("Mysheet");
            var tb2 = ws2.Cell(1, 1).InsertTable(testList);
            const string newHeader = "TestNew";
            for (int i = 0; i < tb2.Fields.Count(); i++)
                tb2.Field(i).Name = string.Format("{0} {1}", newHeader, i);
File Test1.xlsx opens normally. Test2.xlsx opens after a repair process from excel. This is the message which excel provides:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>

-<recoveryLog xmlns="">


<summary>Fehler in Datei 'C:\Test\Test2.xlsx'</summary>

-<repairedRecords summary="Die folgenden Reparaturen wurden durchgeführt:_x000d__x000a__x000d__x000a_">

<repairedRecord>Reparierte Datensätze: Tabelle von /xl/tables/table.xml-Part (Tabelle)</repairedRecord>


Are there some special characters which are not allowed? Or do you have any idea from where it comes?

Kind regards Alexander
Oct 20, 2014 at 10:54 AM
There is still the problem. Also other user were able to reproduce this bug/problem. Any suggestion?
Oct 20, 2014 at 4:32 PM
Your example works. Pick the source code and not the release.
Marked as answer by xandi1987 on 10/22/2014 at 1:47 AM
Oct 22, 2014 at 9:43 AM
Thank you very much. It works.
Dec 12, 2014 at 8:51 AM

I am still getting error and I took source code. I get error:

<?xml version="1.0" encoding="UTF-8" standalone="true"?>

-<recoveryLog xmlns="">


<summary>Errors were detected in file 'D:\TemporaryReports\Test.xlsx'</summary>

-<repairedRecords summary="Following is a list of repairs:">

<repairedRecord>Repaired Records: Table from /xl/tables/table.xml part (Table)</repairedRecord>



Could you please advise?
Dec 12, 2014 at 7:49 PM
What are you doing mafalarz? Are you using the source code? (I haven't released the fix yet)