1

How can I merge two columns {for eg : column Q and column R} in a worksheet using closedxml and c#.

Appreciate any kind of help.

Thanks

Sushmit
  • 51
  • 1
  • 8
  • ...or possibly this https://stackoverflow.com/questions/39651315/how-to-merge-cell-using-closedxml-with-a-dynamic-column-count – TBA Nov 20 '21 at 06:21

1 Answers1

1

First You have to create the worksheet by the title. Then send datatable and work sheet to new function. Then You can create custom excel file.

 var datatable = DivExportToExcelType1(dataDto);
     var ws = workBook.Worksheets.Add(company.Value);
    ExportToExcelType(ws, datatable);
    
     private void ExportToExcelType(IXLWorksheet ws, DataTable datatable)
            {
                var rows = datatable.Rows;
                var Cols = datatable.Columns;
    
    
    
                for (int col = 1; col <= Cols.Count; col++)
                {
                    //create your cols
                }
    
                for (int row = 1; row <= rows.Count ; row++)
                {
                   //create your rows
                }
    
    
                ws.Range("range your cells").Merge(); //for example ws.Range("A11:A19")
            }
Arun_Raja1
  • 207
  • 1
  • 1