I want to merge cell in a header which I want to set on top of the column name in DataGridView
and Header should be in center format.
Just like, I had shown the sample in the image.
I tried some code from this link but it didn’t work for me.
I want to merge cell in a header which I want to set on top of the column name in DataGridView
and Header should be in center format.
Just like, I had shown the sample in the image.
I tried some code from this link but it didn’t work for me.
This code may help you..
wBook = _excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
wSheet.Range(wSheet.Cells(vRow, vColNature), wSheet.Cells(vRow, vColMAX)).Merge()
wSheet.Range(wSheet.Cells(vRow, vColNature), wSheet.Cells(vRow, vColMAX)).WrapText = True
wSheet.Range(wSheet.Cells(vRow, vColNature), wSheet.Cells(vRow, vColMAX)).Font.Bold = True
wSheet.Range(wSheet.Cells(vRow, vColNature), wSheet.Cells(vRow, vColMAX)).Borders.LineStyle = 1
wSheet.Range(wSheet.Cells(vRow, vColNature), wSheet.Cells(vRow, vColMAX)).HorizontalAlignment = Excel.Constants.xlCenter