Unable to add blank header in excel with XLWorkBook

24 Views Asked by At

I am trying to add a blank row and then a datatable with headers in an excel sheet. Problem is if I try to add blank row it comes as a blank entry in second row but header is still there.

Expected output: enter image description here

Actual output:

enter image description here

Code:

using (XLWorkbook wb = new XLWorkbook())
 {
     var tempdata = tableData.Tables[0];
     DataRow blankRow = tempdata.NewRow();
     tempdata.Rows.InsertAt(blankRow, 0);
    
     wb.Worksheets.Add(tempdata);
     
     using (MemoryStream stream = new MemoryStream())
     {
         //save as excel
     }
 }
0

There are 0 best solutions below