grid export function
WINFORMS
gridview ver: 2019.3.917.40
What happens is the excel doc ends up with only the one sheet, the 2nd one.
Why?
What am I doing wrong?
I send in;
a grid Telerik.WinControls.UI.RadGridView objGrid
SheetName
NbrOfGrids
Calling code!
strDocToOpen = exportGrid(radGrid1, "sheetname1", 2);
strDocToOpen = exportGrid(radGrid2, "sheetname2", 2);
Call to Open strDocToOpen
EXPORT Function code!
// export the grid to an excel file
Telerik.WinControls.Export.GridViewSpreadExport exporter = new Telerik.WinControls.Export.GridViewSpreadExport(objGrid)
{
ExportFormat = Telerik.WinControls.Export.SpreadExportFormat.Xlsx
};
Telerik.WinControls.Export.SpreadExportRenderer exporterRenderer = new Telerik.WinControls.Export.SpreadExportRenderer();
exporter.SheetName = strSheetName;
// if more then one grid to be in exceldoc
if (intNbrOfGrids > 1)
{
exporter.FileExportMode = Telerik.WinControls.Export.FileExportMode.NewSheetInExistingFile;
};
string strPathToMyDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
strFileName = "MyDoc";
exporter.RunExport(strPathToMyDocuments + @"\" + strFileName + ".xlsx", exporterRenderer);
Returns (strPathToMyDocuments + @"\" + strFileName + ".xlsx")
WINFORMS
gridview ver: 2019.3.917.40
What happens is the excel doc ends up with only the one sheet, the 2nd one.
Why?
What am I doing wrong?
I send in;
a grid Telerik.WinControls.UI.RadGridView objGrid
SheetName
NbrOfGrids
Calling code!
strDocToOpen = exportGrid(radGrid1, "sheetname1", 2);
strDocToOpen = exportGrid(radGrid2, "sheetname2", 2);
Call to Open strDocToOpen
EXPORT Function code!
// export the grid to an excel file
Telerik.WinControls.Export.GridViewSpreadExport exporter = new Telerik.WinControls.Export.GridViewSpreadExport(objGrid)
{
ExportFormat = Telerik.WinControls.Export.SpreadExportFormat.Xlsx
};
Telerik.WinControls.Export.SpreadExportRenderer exporterRenderer = new Telerik.WinControls.Export.SpreadExportRenderer();
exporter.SheetName = strSheetName;
// if more then one grid to be in exceldoc
if (intNbrOfGrids > 1)
{
exporter.FileExportMode = Telerik.WinControls.Export.FileExportMode.NewSheetInExistingFile;
};
string strPathToMyDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
strFileName = "MyDoc";
exporter.RunExport(strPathToMyDocuments + @"\" + strFileName + ".xlsx", exporterRenderer);
Returns (strPathToMyDocuments + @"\" + strFileName + ".xlsx")