Searched and found the following solution Here Users have given up vote to it but it throwing an exception for me.
MultiFileExportToExcel Unable to cast object of type 'DevExpress.XtraGrid.Views.Grid.GridView' to type 'DevExpress.XtraPrinting.IPrintable'. Unable to cast object of type 'DevExpress.XtraGrid.Views.Grid.GridView' to type 'DevExpress.XtraPrinting.IPrintable'.
Full code is here:
Public Sub MultiFileExportToExcel()
Using saveDialog = New SaveFileDialog()
saveDialog.Filter = "Excel (.xlsx)|*.xlsx"
If saveDialog.ShowDialog() = DialogResult.OK Then
Dim printingSystem = New PrintingSystemBase()
Dim compositeLink = New CompositeLinkBase()
compositeLink.PrintingSystemBase = printingSystem
Dim link1 = New PrintableComponentLinkBase()
link1.Component = CType(GridView1, IPrintable)
Dim link2 = New PrintableComponentLinkBase()
link2.Component = CType(GridView2, IPrintable)
compositeLink.Links.Add(link1)
compositeLink.Links.Add(link2)
Dim options = New XlsxExportOptions()
options.ExportMode = XlsxExportMode.SingleFilePageByPage
compositeLink.CreatePageForEachLink()
compositeLink.ExportToXlsx(saveDialog.FileName, options)
End If
End Using
End Sub
Thank in advance..