Ideally, i would like to export my grids to one file, but seems i will need to create wrapper grid around my grids and it would not fit my scenario. Second option for is to create two separate export files. However, i am getting only second file saved. Here is my approach:
Export(grid, subName, strCenterHeader, alternateText)
Export(grid2, subName2, strCenterHeader2, alternateText)
Protected Sub Export(ByVal grid As RadGrid, _
ByVal subName As String, _
ByVal strCenterHeader As String, _
ByVal alternateText As String)
grid.ExportSettings.FileName = TredisSession.Current.Project.ProjectName.Replace(" ", "_") & "_" & subName & "_Data"
grid.ExportSettings.ExportOnlyData = True
grid.ExportSettings.OpenInNewWindow = True
grid.ExportSettings.UseItemStyles = True
Select Case alternateText
Case "HTML"
grid.ExportSettings.Excel.Format = GridExcelExportFormat.Html
grid.MasterTableView.ExportToExcel()
Case "ExcelML"
grid.ExportSettings.Excel.Format = DirectCast([Enum].Parse(GetType(GridExcelExportFormat), alternateText), GridExcelExportFormat)
grid.MasterTableView.ExportToExcel()
Case "Xlsx"
grid.ExportSettings.Excel.Format = DirectCast([Enum].Parse(GetType(GridExcelExportFormat), alternateText), GridExcelExportFormat)
grid.MasterTableView.ExportToExcel()
Case "PDF"
Dim footerMiddleCell As String = "<?page-number?>"
' to get lanscape orientation
grid.ExportSettings.Pdf.PageHeight = Unit.Parse("200mm")
grid.ExportSettings.Pdf.PageWidth = Unit.Parse("500mm")
grid.ExportSettings.Pdf.PageHeader.MiddleCell.Text = strCenterHeader
grid.ExportSettings.Pdf.PageHeader.MiddleCell.TextAlign = GridPdfPageHeaderFooterCell.CellTextAlign.Center
grid.ExportSettings.Pdf.PageFooter.MiddleCell.Text = footerMiddleCell
grid.ExportSettings.Pdf.PageFooter.MiddleCell.TextAlign = GridPdfPageHeaderFooterCell.CellTextAlign.Center
grid.MasterTableView.ExportToPdf()
Case "Doc"
grid.MasterTableView.ExportToWord()
Case "CSV"
grid.MasterTableView.ExportToCSV()
End Select
End Sub
Thank you