Tuesday, November 14, 2006

Exporting to Office 2007

Office 2007 has gone gold and so has telerik's support for exporting to the Microsoft update. Well, maybe telerik's support is closer to silver, but the support is there nonetheless. Anyone who has tried exporting from grid to Office 2007 has probably discovered that the exported files cannot be read by latest Office version. The problem lies in the encoding used by the grid export method, which currently uses UTF7. This encoding works for current versions of Office, but UTF8 is required for exporting to Office 2007 (an encoding which does not work with older versions of office, of course). To address the problem, telerik introduced two new methods in grid 4.0: ExportToExcel2007 and ExportToWord2007. These methods work just like their ExportToExcel and ExportToWord counterparts except that UTF8 encoding is employed for Office '07 compatibility. Curiously, they do not appear in the Q3 documentation, but I expect that will be fixed soon. I'm also concerned that the method names may cause problems for developers down the road (what happens when Office 2009 comes out?), but that's not a big deal today. If you are a developer who must support Office 2007 and older versions of office (as I expect many are), you now must deal with the task of figuring out which export method to call depending on your user's installed version of Office (thus my belief that this support is more silver than gold). For now, the best approach may be to simply ask users exporting from your site if they are using Office 2007 and then use the appropriate grid export function. You can avoid annoying your users by saving their first response in a cookie and referring to that value for future export calls. While the support isn't automatic, telerik has provided a method that enables continuing compatibility with the (officially) days old Office version. Anybody supporting (or soon to be supporting) Office 2007 users should take note and use these new methods whenever exporting from grid.