This project is read-only.

Why are the column headers not generated in the xslx

Jan 10, 2012 at 9:29 AM


I start to learn the library.


Following the unit tests, I see that although the below method (in WorkSheetWriter.cs), intends to write out the column headers, the generated sheet does not include them.

I've modifed the unit test to send the List<string> of column names as the 6th param, to no avail.

Any suggestion?


        /// <summary>

        /// Pastes a datatable into a worksheet at the location specified and returns the rowindex of the last row.

        /// </summary>

        /// <remarks>

        /// Includes column headers and all columns, or columns if columnNames is supplied.

        /// </remarks>

        public static uint PasteDataTable(DataTable dt, SpreadsheetDocument spreadsheet, WorksheetPart worksheetPart, string column, uint rowIndex, List<string> columnNames, SpreadsheetStyle style)

Jul 29, 2014 at 3:16 AM
Hi YHollander,
Did you have any luck with resolving this issue? I have been working at it all day today.
Jul 29, 2014 at 3:29 AM
This is for anyone who might come across this issue:

I was able to find a temporary fix by using the code at John's site here:

for (int x = 0; x < ds.Tables[i].Columns.Count; x++)
                    string columnName = GetExcelColumnValue(x + 1);                       
                    writer.PasteText(columnName + "1", 
                        ds.Tables[i].Columns[x].ColumnName, style); 
Thanks John!