<?xml version="1.0" encoding="utf-16"?>
<PROG NAME="ZDEMO_EXCEL_GAPPS" VARCL="X" SUBC="1" CNAM="IANNACCI" CDAT="20110823" UNAM="FEMIA" UDAT="20110907" VERN="000012" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" SDATE="20110907" STIME="221339" IDATE="20110907" ITIME="221339" UCCHECK="X">
 <textPool>
  <language SPRAS="E">
   <textElement ID="R" ENTRY="From abap2xlsx to abap2gapps Demo: Hello World" LENGTH="46 "/>
   <textElement ID="S" KEY="P_PATH" ENTRY="D       ." LENGTH="9 "/>
  </language>
 </textPool>
 <source>*&amp;---------------------------------------------------------------------*
*&amp; Report  ZDEMO_EXCEL1
*&amp;
*&amp;---------------------------------------------------------------------*
*&amp;
*&amp;
*&amp;---------------------------------------------------------------------*

REPORT  zdemo_excel_gapps.

DATA: lo_excel                TYPE REF TO zcl_excel,
      lo_excel_writer         TYPE REF TO zif_excel_writer,
      lo_worksheet            TYPE REF TO zcl_excel_worksheet,
      lo_hyperlink            TYPE REF TO zcl_excel_hyperlink,
      column_dimension        TYPE REF TO zcl_excel_worksheet_columndime.

DATA: lv_file                 TYPE xstring,
      lv_bytecount            TYPE i.


PARAMETERS: consumer      TYPE zoauth2_consumer_name,
            username      TYPE zoauth2_user_name,
            proxyhst      TYPE string,
            proxysrv      TYPE string,
            ssl_id        TYPE ssfapplssl DEFAULT &apos;ANONYM&apos;.

START-OF-SELECTION.


  &quot; Creates active sheet
  CREATE OBJECT lo_excel.

  &quot; Get active sheet
  lo_worksheet = lo_excel-&gt;get_active_worksheet( ).
  lo_worksheet-&gt;set_title( ip_title = &apos;Sheet1&apos; ).
  lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 2 ip_value = &apos;Hello world&apos; ).
  lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 3 ip_value = sy-datum ).
  lo_worksheet-&gt;set_cell( ip_column = &apos;C&apos; ip_row = 3 ip_value = sy-uzeit ).
  lo_hyperlink = zcl_excel_hyperlink=&gt;create_external_link( iv_url = &apos;https://cw.sdn.sap.com/cw/groups/abap2xlsx&apos; ).
  lo_worksheet-&gt;set_cell( ip_column = &apos;B&apos; ip_row = 4 ip_value = &apos;Click here to visit abap2xlsx homepage&apos; ip_hyperlink = lo_hyperlink ).

  column_dimension = lo_worksheet-&gt;get_column_dimension( ip_column = &apos;B&apos; ).
  column_dimension-&gt;set_width( ip_width = 11 ).

  CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007.
  lv_file = lo_excel_writer-&gt;write_file( lo_excel ).

  &quot; Save the file ONLINE
  DATA: lo_spreadsheet      TYPE REF TO zcl_docs_spreadsheet.

  CREATE OBJECT lo_spreadsheet
    EXPORTING
      i_consumer_name = consumer
      i_user_name     = username
      i_proxy_host    = proxyhst
      i_proxy_service = proxysrv
      i_ssl_id        = ssl_id.

  lv_bytecount  = XSTRLEN( lv_file ).

  lo_spreadsheet-&gt;zif_docs~upload(  i_document = lv_file
       i_title = &apos;demo1froma2xlsx&apos; i_size = lv_bytecount ).</source>
</PROG>
