100% found this document useful (1 vote)
807 views11 pages

ALV2XLSX User Guide

This document provides user documentation for the ABAP class ZCL_ALV2XLSX, which allows exporting data from SAP ALV grids and tables to Excel file formats. The class contains attributes for handling the document proxy, spreadsheet, and OLE2 object. Methods are included for constructing the class object, inserting rows and cells, writing rows and tables with or without formatting, and saving/closing the document. Appendices define the structure for formatting items and color palette constants. The class allows exporting ALV grid, LVC pool, and SLIS pool data to Excel with formatting and features like those of an ALV grid.

Uploaded by

ongkecantho
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
807 views11 pages

ALV2XLSX User Guide

This document provides user documentation for the ABAP class ZCL_ALV2XLSX, which allows exporting data from SAP ALV grids and tables to Excel file formats. The class contains attributes for handling the document proxy, spreadsheet, and OLE2 object. Methods are included for constructing the class object, inserting rows and cells, writing rows and tables with or without formatting, and saving/closing the document. Appendices define the structure for formatting items and color palette constants. The class allows exporting ALV grid, LVC pool, and SLIS pool data to Excel with formatting and features like those of an ALV grid.

Uploaded by

ongkecantho
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

ABAP Class ZCL_ALV2XLSX

User guide
Hung Hoang (Hoangmanhung@gmail.com)
9/21/2010
ABAP CLASS ZCL_ALV2XLSX

Table of Contents
OVERVIEW .................................................................................................................................................... 2
DOCUMENTS................................................................................................................................................. 3
Attributes of the class: ZCL_ALV2XLSX .............................................................................................. 3

Methods of the class: ZCL_ALV2XLSX ................................................................................................. 3


CONSTRUCTOR .................................................................................................................................. 3
INSERT_ROWS .................................................................................................................................... 3
WRITE_CELL ........................................................................................................................................ 4
WRITE_ROW ........................................................................................................................................ 4
WRITE_TABLE ..................................................................................................................................... 4
WRITE_TABLE_LVC ............................................................................................................................ 5
WRITE_TABLE_SLIS ........................................................................................................................... 6
WRITE_TABLE_ALV ............................................................................................................................ 7
FORMAT_CELLS .................................................................................................................................. 8
SAVE_DOCUMENT .............................................................................................................................. 9
CLOSE_DOCUMENT ........................................................................................................................... 9
APPENDIX ................................................................................................................................................... 10
Structure: SOI_FORMAT_ITEM ............................................................................................................ 10

Color palette: ......................................................................................................................................... 10

1 September 2010
ABAP CLASS ZCL_ALV2XLSX

Overview

Purpose:

ABAP class ZCL_ALV2XLSX is useful for ABAP developer, in SAP system.

You can use this class to export data on SAP ALV grid to xlsx / xls file format.

Main features:

- Export a CL_GUI_ALV_GRID object to xlsx/xls file with list header.


- Export a table with field catalog, sort table, filter table (in SLIS type pools) to xlsx/xls file.
- Export a table with field catalog, sort table, filter table (in LVC type pools) to xlsx/xls file.
- Export a raw data table, a record, a cell ... to xlsx/xls file.

Compatible with:

- SAP ECC 6.0


- MS Excel 2003.
- MS Excel 2007.
- MS Excel 2010 (not test).

2 September 2010
ABAP CLASS ZCL_ALV2XLSX

Documents
Attributes of the class: ZCL_ALV2XLSX:

Attributes Type / Type ref to Description


GO_PROXY I_OI_DOCUMENT_PROXY To handle Proxy control
GO_SPREADSHEET I_OI_SPREADSHEET To handle DOI object
GO_OLE_APP OLE2_OBJECT To handle OLE2 object

Methods of the class: ZCL_ALV2XLSX:


(Document use SHEET as instance of class ZCL_ALV2XLSX)

CONSTRUCTOR
You use this method to create a new document (sheet) in the Office Apps

CREATE OBJECT SHEET


EXPORTING
I_DOCUMENT_URL = 'C:\template.xls'
I_XLS = SPACE
I_PARAENT = CL_GUI_CONTAINER=>DEFAULT_SCREEN
I_INPLACE = 'X'
I_NO_FLUSH = 'X'
.

Parameter Optional Description


Xlsx / xls template file path.
I_DOCUMENT_URL X
' ' : Create a new document (don't use template)
Xls flag
I_XLS X 'X': Create xls document
' ' : Create xlsx document

INSERT_ROWS
You use this method to insert a numbers of empty rows into sheet.

CALL METHOD SHEET->INSERT_ROWS


EXPORTING
I_TOP = 1
I_NUMBER = 10
.

Parameter Optional Description


I_TOP Top edge of the rows
I_NUMBER Number of empty rows need insert

3 September 2010
ABAP CLASS ZCL_ALV2XLSX

WRITE_CELL
You use this method to insert a value into a sheet cell w/o format.

CALL METHOD SHEET->WRITE_CELL


EXPORTING
I_ROW =1
I_COLUMN = 2
I_VALUE = 'Cell value'
.

Parameter Optional Description


I_ROW Row position of cell
I_COLUMN Column position of cell
I_VALUE Cell value

WRITE_ROW
You use this method to insert an ABAP work area into a sheet line w/o format.

CALL METHOD SHEET->WRITE_ROW


EXPORTING
I_TOP =1
I_LEFT = 2
I_RECORD = wa_data
.

Parameter Optional Description


I_TOP Top position of the record
I_LEFT Left position of the record
I_RECORD Word area (record)

WRITE_TABLE
You use this method to insert a raw data table into sheet, at a specific position.

CALL METHOD SHEET->WRITE_TABLE


EXPORTING
I_TOP =1
I_LEFT = 2
IT_OUTTAB = gt_table
.

Parameter Optional Description


I_TOP Top position of the table
I_LEFT Left position of the table
IT_OUTTAB Data table

4 September 2010
ABAP CLASS ZCL_ALV2XLSX

WRITE_TABLE_LVC
You use this method to insert a data table into sheet with field catalog table (LVC), sort table (LVC), filter
table (LVC) like build an ALV grid.

CALL METHOD SHEET->WRITE_TABLE_LVC


EXPORTING
IT_OUTTAB = gt_table
IT_FIELDCAT_LVC = gt_fieldcat_lvc
IT_SORT_LVC = gt_sort_lvc
IT_FILTER_LVC = gt_filter_lvc
IT_LISTHEADER_LVC = gt_list_header
I_TOP =1
I_LEFT =1
I_NO_COLUMNS_HEADER = SPACE
I_FORMAT_COL_HEADER = wa_column_head_format
I_FORMAT_SUBTOTAL = wa_subtotal_format
I_FORMAT_TOTAL = wa_total_format
.

Parameter Optional Description


IT_OUTTAB Data table
Field catalog table (LVC)
Use to set columns characteristics (like ALV) such as
- No display,
IT_FIELDCAT_LVC - No display zero,
- Currency dependence,
- Display columns subtotal, columns total
- ...
IT_SORT_LVC X Sort table (LVC)
IT_FILTER_LVC X Filter table (LVC)
IT_LISTHEADER_LVC X List header (title, subtitle ...)
I_TOP X Top position of the data block
I_LEFT X Left position of the data block
'X': No display column headers
I_NO_COLUMNS_HEADER X
' ' : Display column headers
Column headers format: Font, color, align, number format ...
I_FORMAT_COL_HEADER X
Type SOI_FORMAT_ITEM (ref to SOI_FORMAT_ITEM)
Subtotal lines format: Font, color, align, number format ...
I_FORMAT_SUBTOTAL X
Type SOI_FORMAT_ITEM (ref to SOI_FORMAT_ITEM)
Total line format: Font, color, align, number format ...
I_FORMAT_TOTAL X
Type SOI_FORMAT_ITEM (ref to SOI_FORMAT_ITEM)

5 September 2010
ABAP CLASS ZCL_ALV2XLSX

WRITE_TABLE_SLIS
You use this method to insert a data table into sheet with field catalog table (SLIS), sort table (SLIS), filter
table (SLIS) like build an ALV grid.

CALL METHOD SHEET->WRITE_TABLE_LVC


EXPORTING
IT_OUTTAB = gt_table
IT_FIELDCAT = gt_fieldcat_lvc
IT_SORT = gt_sort_lvc
IT_FILTER = gt_filter_lvc
IT_LISTHEADER = gt_list_header
I_TOP =1
I_LEFT =1
I_NO_COLUMNS_HEADER = SPACE
I_FORMAT_COL_HEADER = wa_column_head_format
I_FORMAT_SUBTOTAL = wa_subtotal_format
I_FORMAT_TOTAL = wa_total_format
.

Parameter Optional Description


IT_OUTTAB Data table
IT_FIELDCAT Field catalog table (SLIS), like method WRITE_TABLE_LVC
IT_SORT X Sort table (SLIS)
IT_FILTER X Filter table (SLIS)
IT_LISTHEADER X List header (title, subtitle ...)
I_TOP X Top position of the data block
I_LEFT X Left position of the data block
'X': No display column headers
I_NO_COLUMNS_HEADER X
' ' : Display column headers
Column headers format: Font, color, align, number format ...
I_FORMAT_COL_HEADER X
Type SOI_FORMAT_ITEM (ref to SOI_FORMAT_ITEM)
Subtotal lines format: Font, color, align, number format ...
I_FORMAT_SUBTOTAL X
Type SOI_FORMAT_ITEM (ref to SOI_FORMAT_ITEM)
Total line format: Font, color, align, number format ...
I_FORMAT_TOTAL X
Type SOI_FORMAT_ITEM (ref to SOI_FORMAT_ITEM)

6 September 2010
ABAP CLASS ZCL_ALV2XLSX

WRITE_TABLE_ALV
You use this method to insert data got from ALV object (CL_GUI_ALV_GRID) into sheet.

CALL METHOD SHEET->WRITE_TABLE_ALV


EXPORTING
IO_GRID = go_alv_grid
IT_LISTHEADER = gt_list_header
I_TOP =1
I_LEFT =1
I_NO_COLUMNS_HEADER = SPACE
I_FORMAT_COL_HEADER = wa_column_head_format
I_FORMAT_SUBTOTAL = wa_subtotal_format
I_FORMAT_TOTAL = wa_total_format
.

Parameter Optional Description


IO_GRID ALV object, instance of class CL_GUI_ALV_GRID
IT_LISTHEADER X List header (title, subtitle ...)
I_TOP X Top position of the data block
I_LEFT X Left position of the data block
'X': No display column headers
I_NO_COLUMNS_HEADER X
' ' : Display column headers
Column headers format: Font, color, align, number format ...
I_FORMAT_COL_HEADER X
Type SOI_FORMAT_ITEM (ref to SOI_FORMAT_ITEM)
Subtotal lines format: Font, color, align, number format ...
I_FORMAT_SUBTOTAL X
Type SOI_FORMAT_ITEM (ref to SOI_FORMAT_ITEM)
Total line format: Font, color, align, number format ...
I_FORMAT_TOTAL X
Type SOI_FORMAT_ITEM (ref to SOI_FORMAT_ITEM)

7 September 2010
ABAP CLASS ZCL_ALV2XLSX

FORMAT_CELLS
You use this method to format sheet cells

CALL METHOD SHEET->FORMAT_CELLS


EXPORTING
I_TOP =1
I_LEFT =1
I_ROWS = 100
I_COLUMNS =5
I_FONT_NAME = 'Arial'
I_FONT_SIZE = 10
I_FONT_STYLE = 'BI'
I_ALIGN = 'L'
I_FRONT_COLOR = 35
I_BACK_COLOR = 26
I_FRAMETYP = 111
I_FRAMECOLOR =1
I_NUMBER =1
I_DECIMALS =2
.

Parameter Optional Description


I_TOP Top position of cells block need to format
I_LEFT Left position
I_ROWS X Number of rows in cells block
I_COLUMNS X Number of columns in cells block
I_FONT_NAME X Font family
I_FONT_SIZE X Font size
Font style of cells
- 'B' : Bold
I_FONT_STYLE X
- 'I' : Italic
- 'BI' (or 'IB'): Bold Italic
Cell alignment:
- 'L': Left
I_ALIGN X
- 'C': Centered
- 'R': Right
I_FRONT_COLOR X Characters color (ref to Color palette)
I_FRAMETYP X Cells border
I_FRAMECOLOR X Cells background color (ref to color palette)
Number format:
- 1: Display as a simple number
I_NUMBER X - 2: Scientific display
- 3: Display as a percentage

I_DECIMALS X Number of decimal places

8 September 2010
ABAP CLASS ZCL_ALV2XLSX

SAVE_DOCUMENT
You use this method save document on presentation server

CALL METHOD SHEET->SAVE_DOCUMENT


EXPORTING
I_SAVE_PATH = 'C:\Export_file.xls'
.

Parameter Optional Description


I_SAVE_PATH File path need to save on presentation server

CLOSE_DOCUMENT
You use this method to close document and release data.

CALL METHOD SHEET->CLOSE_DOCUMENT


.

9 September 2010
ABAP CLASS ZCL_ALV2XLSX

Appendix
Structure: SOI_FORMAT_ITEM

Field Type Description


Name C(256) Name of the cells block ( no need in ZCL_ALV2XLSX class)
Front i Character color (ref to color palette)
Back I Background color (ref to color palette)
Font C(256) Name of the font family. The following values are permitted:
- 'Arial'
- 'Courier New'
- 'Times New Roman'
Size i Font size
'-1': Unchanged
Bold i - '1': Bold
- '0': Normal
- '-1': Unchanged
Italic i - '1': Italic
- '0': Normal
- '-1': Unchanged
Align i Alignment:
- '-1': Unchanged
- '0': Right-justified
- '1': Centered
- '2': Left-justified
Frametype i Control byte for setting the frame
'-1': Unchanged
Framecolor i Frame color (see color palette)
'-1': Unchanged
Curency C(3) ISO standard currency code
Number i Specifies the format of a cell in a range.
- 1: Display as a simple number
- 2: Scientific display
- 3: Display as a percentage
Decimals i Number of decimal places

COLOR PALETTE:
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30
31 32 33 34 35 36
37 38 39 40 41 42
43 44 45 46 47 48
9 50 51 52 53 54
55 56 57

10 September 2010

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy