Hi
We're currently allowing our users to export data in a RadGrid to Excel using the RadGrid1.MasterTableView.ExportToExcel() method. The users can group the data in the grid while using the web application. We need to make a few modifications to the grid - both structure and data - when the users clicks an 'Export to Excel' button.
While we know how the logic for making the changes below, our big issue is that none of these changes take effect during the 'Export to Excel' button click event.
We're facing a few issues:
1. For the export we need to normalise the grid, removing any grouping, to a flat structure (i.e. columns and rows only). This includes making a column visible that's not visible while the grouping is in effect.
2. The grid contains images (eg. a check mark for a boolean field). All the images appear as broken links in the Excel file. We'd like to simply replace the image with a 'Yes' / 'No' or 'True' / 'False' as text. Note that logic depends on the boolean values returned from the database, so this replacement must be done on the fly during the export (i.e. we can't change the backing value in the grid).
3. The sortable columns have column names displayed in hyperlinks in the Excel file. While they work fine in the browser, they are broken in the Excel file. We need to switch the hyperlink off and just have normal text headings (in bold possibly?).
4. Command line (specified as a CommandItemTemplate) appears in the spreadsheet. We need to prevent this from appearing.
5. When opening the Excel file, the following error message appears: 'The file you are trying to open is in a different format than specified by the file extension ..' and warns the user of possible corruption and security concerns. Although it is mentioned on http://www.telerik.com/help/aspnet-ajax/grdexport.html, it doesn't address the issue. Is there a way to prevent this from appearing?
We've tried a number of options but to no avail. Do we need to rebind the grid? While testing, a grid.Rebind() causes a null exception. Obviously any changes that are made must only apply to the exported Excel file and not have any side effect on the grid state as displayed in the browser.
We've also tried using ExportToCsv() and while this addresses some of the issues above, it doesn't help with the structure change & data modification.
Thanks
We're currently allowing our users to export data in a RadGrid to Excel using the RadGrid1.MasterTableView.ExportToExcel() method. The users can group the data in the grid while using the web application. We need to make a few modifications to the grid - both structure and data - when the users clicks an 'Export to Excel' button.
While we know how the logic for making the changes below, our big issue is that none of these changes take effect during the 'Export to Excel' button click event.
We're facing a few issues:
1. For the export we need to normalise the grid, removing any grouping, to a flat structure (i.e. columns and rows only). This includes making a column visible that's not visible while the grouping is in effect.
2. The grid contains images (eg. a check mark for a boolean field). All the images appear as broken links in the Excel file. We'd like to simply replace the image with a 'Yes' / 'No' or 'True' / 'False' as text. Note that logic depends on the boolean values returned from the database, so this replacement must be done on the fly during the export (i.e. we can't change the backing value in the grid).
3. The sortable columns have column names displayed in hyperlinks in the Excel file. While they work fine in the browser, they are broken in the Excel file. We need to switch the hyperlink off and just have normal text headings (in bold possibly?).
4. Command line (specified as a CommandItemTemplate) appears in the spreadsheet. We need to prevent this from appearing.
5. When opening the Excel file, the following error message appears: 'The file you are trying to open is in a different format than specified by the file extension ..' and warns the user of possible corruption and security concerns. Although it is mentioned on http://www.telerik.com/help/aspnet-ajax/grdexport.html, it doesn't address the issue. Is there a way to prevent this from appearing?
We've tried a number of options but to no avail. Do we need to rebind the grid? While testing, a grid.Rebind() causes a null exception. Obviously any changes that are made must only apply to the exported Excel file and not have any side effect on the grid state as displayed in the browser.
We've also tried using ExportToCsv() and while this addresses some of the issues above, it doesn't help with the structure change & data modification.
Thanks