I am exporting DataGridViews to Excel using ClipboardCopyMode. However, I want to format the header and the cell width/height, because the cells aren't adjusting normally.
Also, I want to add some data in it apart of the data from the DataGridView.
This is the code of the sub I have:
Dim appExcel As Excel.Application
Dim wbExcel As Excel.Workbook
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("es-US")
If Combo.SelectedValue.ToString().Trim() = "Something" Then
dgv.SelectAll()
dgv.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
Clipboard.SetDataObject(dgv.GetClipboardContent())
End If
appExcel = New Excel.Application
appExcel.SheetsInNewWorkbook = 1
wbExcel = appExcel.Workbooks.Add
appExcel.Visible = True
wbExcel.Worksheets(1).Range("A3").Select()
wbExcel.Worksheets(1).Paste()
How can I do these things and beautify my exported Excel?
Thanks in advance