WebClient UI Export to Spreadsheet with abap2xlsx
We’re happy to celebrate 200 members in the abap2xlsx project:
This blog provides the background story why I’ve created this code sample. If you just want the code then directly open GitHub Repository: SAP CRM Web Client UI Export to Spreadsheet with abap2xlsx.
Limitations of the standard Export to Spreadsheet functionality
According to the WebClient UI Framework documentation on Setting Up the System a XML export is only possible with Microsoft Internet Explorer with ActiveX, and one a version of Microsoft Excel versions under Windows. But I think today as Firefox (Version 2.0 and 3.0 according to the Product Availability Matrix ) is also a supported Browser for SAP CRM and other office products support the Open Office XML that limitation should be removed. Thanks to my new SAP Mentor colleague Ivan Femia who started the abap2xlsx last year this is now also possible.
Internationalization problems with the XML export
It started two month ago when I got a call from one of our SAP CRM users in Switzerland. He told me that he has a problem using the Export to Spreadsheet function. The problem occurred in value columns exported from the Opportunity search result list. I’ve connected to his machine and saw the problem.The columns containing the Opportunity value where not recognized as a number. Instead they where displayed as text. So i.e. no calculation of the total was possible.
That was caused by that fact that the machines “Regional and Language Options” where set to “German (Switzerland)”. The main difference to “German (Germany)” is that Numbers are displayed as 123’456’789.00 instead of 123.456.789,00. As SAP doesn’t support this decimal notation (Defaults in SU01 or SU3) the export as 123.456.789,00 was used.
Way to the solution
As I already thought about replacing the standard Export to Spreadsheet functionality with abap2xlsx. The call from Switzerland was the last kick I’ve needed to start it. As the Export to Spreadsheet is a generic functionality of the WebClient UI Framework I first searched for a way to provide the replacement without any modification. The trick is to create an external alias in transaction SICF which uses path of the standard functionality but replaces it with the custom one.
From that point it was straight forward. Inspired by the functionality of the standard handler class CL_CHTMLB_CONFIG_TAB_EXCEL_EXP I’ve created the class ZCL_CHTMLB_TAB_EXCEL_EXPORT using abap2xlsx to create the .XLSX file. It was a bit tricky to provide the fields to abap2xlsx in the right format. But with the code completion in NetWeaver 7.02 I found the needed method.
Sow now you can check out the solution at GitHub Repository: SAP CRM Web Client UI Export to Spreadsheet with abap2xlsx.