Our ASP.NET web application, which uses the Telerik RadGrid, 2.0.2.0, needs to be updated for Windows 7 compatibility. The issue is that the existing functionality to export an Excel file does not produce an Excel file that is compatible with Office 2007, which is part of our new Windows 7 set of common applications.
The issue is with these lines of code:
ExportXLS.Telerik.WebControls.RadGrid RadGrid1 = new
ExportXLS.Telerik.WebControls.RadGrid();
RadGrid1.MasterTableView.ExportToExcel(TableName, true, false);
We discovered that there is another dll, RadGrid.Net2 version 4.5.0.0, which includes a “ExportToExcel2007” method that is not available in the 2.0 version of the dll. This method does produce a valid Excel file that can be opened with Excel 2007.
Telerik.WebControls.RadGrid RadGrid1 = new Telerik.WebControls.RadGrid();
RadGrid1.MasterTableView.ExportToExcel2007(TableName, true, false);
The problem is that there appears to be drastic differences between the two dlls and switching over to use the new dll didn't look easy. Our intended solution was to reference both dlls in the application but use the newer one only in the screen that is having the problem with creating a 2007 compatible Excel file.
Using the following article as a guide,
http://blogs.msdn.com/b/ansonh/archive/2006/09/28/extern-alias-walkthrough.aspx
we made the following small changes:
Added a reference in the web project to "RadGrid.Net2.dll" and adjusted the alias property of this reference to "ExportXLS"
Add this to the top of the ExportExcel.aspx.cs code-behind page:
extern alias ExportXLS;
Then, instantiated a radgrid using the new dll by referring to the qualified reference of the radgrid.net2.dll:
ExportXLS.Telerik.WebControls.RadGrid RadGrid1 = new ExportXLS.Telerik.WebControls.RadGrid();
Modified the ExportToExcel method to use the 2007 counterpart method:
RadGrid1.MasterTableView.ExportToExcel2007(TableName, true, false);
This solved the issue with the ExportExcel.aspx page and the screen now produces a Excel 2007 compatible Excel spreadsheet, however, we were surprised that this change broke other pages in the application that uses RadGrid. This is the error:
c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7ff38b9a\2680aee3\App_Web_systemmapsearch.ascx.a97e7c59.tlmhafnf.0.cs(251): error CS0433:
The type 'Telerik.WebControls.GridRowIndicatorColumn'
exists in both
'c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\7ff38b9a\2680aee3\assembly\dl3\cd8ec314\002177c0_d2e8cb01\RadGrid.DLL'
and
'c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7ff38b9a\2680aee3\assembly\dl3\428a2b2d\002177c0_d2e8cb01\RadGrid.Net2.DLL'
My expectation was that the other web pages would continue to use the unqualified older 2.0.2.0 version of the RadGrid.dll and would continue to work, but this is not the case.
Here is some of the code from the code behind of the user control, SystemMapSearch.ascx, that fails to load:
<%@ Register TagPrefix="radG" Namespace="Telerik.WebControls" Assembly="RadGrid" %>
<radg:radgrid id="RadGrid1" cssclass="RadGrid" runat="server" allowpaging="True" allowsorting="True" gridlines="none"
pagesize="20" width="100%" borderwidth="0" AutoGenerateColumns="False">
I have tried to change the NameSpace directive to include the global namespace, but this results in an invalid reference:
<%@ Register TagPrefix="radG" Namespace="global::Telerik.WebControls" Assembly="RadGrid" %>
Why does changing the ExportExcel.aspx page break the other pages and what do I have to do to fix the issue?