Você está na página 1de 6

11/13/2014

Download data from web ui to Excel and PPT - CRM - SCN Wiki
Getting Started New sletters

Welcome, Guest

Login

Register

Store

Search the Community

Products

Services & Support

About SCN

Downloads

Industries

Training & Education

Partnership

Developer Center

Lines of Business

University Alliances

Events & Webinars

Innovation

CRM / / CRM Web Client UI Framework

Download data from web ui to Excel and PPT


Added by ArunKumar Balakrishnan, last edited by Gregor Wolf on May 11, 2012

Link to Content's target Space :


http://w iki.sdn.sap.com/w iki/display/CRM/CRM+Web+Client+UI+Framew ork

Applies to:
CRM 6.0/7.0

Summary
Dow nload data from w eb ui to Excel and Pow erpoint presentation w ith formatting options using ActiveXObjects and Javascript.
As an alternative for an Excel Export that doesn't require ActiveX check out WebClient UI Export to Spreadsheet w ith abap2xlsx

Author(s):
Com pany:

Accenture

Created on:

May'11 - 2010

Author(s) Bio
Arun Kumar is a CRM developer w orking w ith Accenture India.
Exporting data to a file from w eb ui is already available in CRM but it is limited to certain file types. For example data cannot be dow nloaded to an Excel file or Pow erpoint presentation. The 'Export to
Excel' button available in tableview tag dow nloads the file as an XML spreadsheet and not to an Excel file.
This w iki explains how to dow nload data to an Excel file and Pow erpoint presentation using ActiveXObjects in Javascript. We do not use SICF service or any handler class.
I have created a value node and populated some data and displayed it in a Table View and added a button 'Dow nload to Excel' w hich triggeres the Javascript function 'dow nload()' onclientclick. The
entire dow nload function is w ritten in the page layout.
( Note: I w as not able to save the w iki w ith standard scripting and activex keyw ords. So i have added the coding as im age as per the advice from SDN support)

Download to Excel function:


Create an Excel w orkbook using acitvexobject and get the reference in a variable 'Excel'. ( I have used AXO to refer active x objects. I cant use the original keyw ord. )

Excel = new AXO("Excel.Application");


Add Workbooks to the file. The object reference is passed to a variable'Workbook'.

Workbook = Excel.Workbooks.Add();
This reference variable 'Workbook' has a list of properties and methods that can be used to format the Excel file further. These are available in the Microsoft msdn library.
Now w e can directly add values to the Excel sheet that is active in the Excel w orkbook.

Workbook.ActiveSheet.Cells(1,1).Value = "Hello";
This statement w rites the value 'Hello' to cell 1:1 of the first sheet in the Excel file.
Adding background color to a range of cells,

Workbook.ActiveSheet.Range("A1:F1").Interior.ColorIndex = 43;

http://wiki.scn.sap.com/wiki/display/CRM/Download+data+from+web+ui+to+Excel+and+PPT

1/6

11/13/2014

Download data from web ui to Excel and PPT - CRM - SCN Wiki

This statement adds color from cell A1 to F1.


All formatting options including adding formula to a cell, condition formatting, inserting images etc., can be done using ActiveXObjects.
Finally the Excel file must be made visible.

Excel.Visible = "true";
The file can be saved directly to the user desktop.

Workbook.SaveAs( <filename>);

Download to PPT
Create a pow erpoint application using AXO.

var myApp = new AXO("PowerPoint.Application");


Add Presentations to the application and slides to the presentation. Once the clides are created, add tables to populate the data.

var presentation = myApp.Presentations.Add();


presentation.Slides.Add(1,12);
presentation.Slides(1).Shapes.AddTable(7, 6, 60, 120, 600, 316);
Data can be populated to table cells by referring to the cell location.

presentation.Slides(1).Shapes(1).Table.Cell(1, 1).Shape.TextFrame.TextRange.Text = "Product ID";


Finally the presentation is made visible.

myApp.Visible = true;

Tableview:

Downloaded Excel file:

Coding:
http://wiki.scn.sap.com/wiki/display/CRM/Download+data+from+web+ui+to+Excel+and+PPT

2/6

11/13/2014

Download data from web ui to Excel and PPT - CRM - SCN Wiki

http://wiki.scn.sap.com/wiki/display/CRM/Download+data+from+web+ui+to+Excel+and+PPT

3/6

11/13/2014

Download data from web ui to Excel and PPT - CRM - SCN Wiki

http://wiki.scn.sap.com/wiki/display/CRM/Download+data+from+web+ui+to+Excel+and+PPT

4/6

11/13/2014

Download data from web ui to Excel and PPT - CRM - SCN Wiki

Thanks & Regards,


Arun Kumar

download

excel

ppt

activex

crm

webclientui

webui

5 Comments
Uday Kumar Reddy Velagacharla
Hi Arun,
I got the similar kind of requirement for dow nloading the data into Excel from UI. I did the same steps but w hen i had clicked on the button in w hich excel dow nload has to be done, nothing is
happening. Could you please let me know any more steps required inorder to trigger the logic behind the button.
If you dont mind, could you please provide your mail id so that i can explain more by giving screenshots.
Thanks & Regards,
Uday

Gregor Wolf
Hi Uday,
I think the approach show n by Arun could be problematic in a environment w here you can't use Microsoft Internet Explorer. A better idea if you need nicely formatted Excel files is the
abap2xlsx project available at https://cw .sdn.sap.com/cw /groups/abap2xlsx. A standard solution for Excel dow nloads is the Excel dow nload available in all table view s.
Best regards
Gregor

http://wiki.scn.sap.com/wiki/display/CRM/Download+data+from+web+ui+to+Excel+and+PPT

5/6

11/13/2014

Download data from web ui to Excel and PPT - CRM - SCN Wiki

ArunKumar Balakrishnan
Hi Gregor,
The abap2xlsx project dow nloads the file in .xlsx format (Open XML Format Spreadsheet file) and not in an Excel format. .Xlsx file is similar to a zipped file package of XML spreadsheets. And
the standard 'Export to Excel' available is table view , DOWNLOADS XML FILES and not Excel files. The 'Export to Excel' event handler class is CL_CHTMLB_CONFIG_TAB_EXCEL_EXP.
Hi Uday,
My mail id is available in my business card.
Regards,
Arun

Gregor Wolf
Hi Arun,
as there are free converters for older Excel Version to read the XLSX format I don't see a problems here. The Export to excel w orks also fine in Excel 2003.
Best regards
Gregor

Guest
Hi Arun,
I am also using the same code w hat you suggested . But nothing is happening and i am getting java script error as mentioned below .
1. I tried to get your email id through your business card but i am not able to see it. Could you please send me your email id.
You can send it on my email id kapilkumar.nitj@gmail.com
2. Also can you please tell is there any special setup needed for active x object.
Please provide me your valuable inputs for this requirement. I w ill really appreciate your help.
syntax error.
1. BSPWDAPPLICATION.DO
2. OBJECTEXPECTED
EVENT.JS
Thanks & Regards,
Kapil Kumar

Contact Us
Privacy

SAP Help Portal


Terms of Use

Legal Disclosure

Copyright

Follow SCN

This ad is supporting your extension ruul (screen ruler): More info | Privacy Policy | Hide on this page

http://wiki.scn.sap.com/wiki/display/CRM/Download+data+from+web+ui+to+Excel+and+PPT

6/6

Você também pode gostar