Worksheet headers blank when importing from a data table or data view

I’m exporting data queries to Excel and then possibly to PDF. My column headers are not showing up even when setting the printheadings set to true. How do I set the headers in the worksheet when importing from a dataview?

Could you please elaborate your need? What column headers are not shown? Could you please post your sample code here?

The column headers from the dataview are not importing into the excel worksheet. Example, column 1 in the database is “ContainerNo”, so in the first row of that worksheet should be “ContainerNo” followed by the rest of the column names. Row 2 is where the data should start.

Public Shared Function GenerateExcelDoc(ByVal oView As DataView) As Excel.Excel

Dim oExcel As New Excel.Excel
Dim oLic As New Aspose.Excel.License

oLic.SetLicense(“Aspose.Custom.lic”)

With (oExcel.Worksheets(0))

.PageSetup.Orientation = Excel.PageOrientationType.Landscape
.PageSetup.PrintGridlines = True
.PageSetup.PrintHeadings = True
.IsRowColumnHeadersVisible = True

.Name = “Export from AdHoc”

.Cells.ImportDataView(oView, 1, 1, True)

End With

Return oExcel

End Function

Importing column header of data view is not supported in earlier version. I added this feature in this attached dll.

Please change your code to:

.Cells.ImportDataView(oView, True, 1, 1, True)

That worked, thanks!