Download to Excel - multiple sheets
hi All,
I successfully create a xls with multiple worksheets
<b>Method 1:</b>(http://www.sapdevelopment.co.uk/ms/ms_excel.htm)
CREATE OBJECT application 'excel.application'
CALL METHOD OF sheet 'Cells' = cells
EXPORTING #1 = myY #2 = myX.
SET PROPERTY OF cells 'Value' = 'hello'.
But this way of cell by cell populating, is too slow; I have 10,000 rows of records to download to excel as report.
Then i tried second way <b>Method 2:</b>
CALL FUNCTION 'XXL_SIMPLE_API'
This is much faster, but it does not allow me to have multiple sheets.
Can anyone advise how to speed up the process using method 1 ?
Thanks in advance.
Ee Siong
Try this....
*& Report ZETA_EXCEL_DOWNLOAD_CLIPBOARD *
report zeta_excel_download_clipboard .
include ole2incl.
data: w_cell1 type ole2_object,
w_cell2 type ole2_object.
*--- Ole data Declarations
data: h_excel type ole2_object, " Excel object
h_mapl type ole2_object, " list of workbooks
h_map type ole2_object, " workbook
h_zl type ole2_object, " cell
h_f type ole2_object, " font
gs_interior type ole2_object, " Pattern
worksheet type ole2_object,
h_cell type ole2_object,
h_cell1 type ole2_object,
range type ole2_object,
h_sheet2 type ole2_object,
h_sheet3 type ole2_object,
gs_font type ole2_object,
flg_stop(1) type c.
Internal table Declaration
data: begin of t_excel occurs 0,
vkorg(20) type c, "Sales Org
vbtyp(20) type c, "Document Category
auart(20) type c, "Document Type
ernam(20) type c, "Created By
vbeln(20) type c, "Document Number
posnr(20) type c, "Item Number
erdat(20) type c, "Created Date
vdatu(20) type c, "Header Requested Delivery Date
reqdat(20) type c, "Request date
condat(20) type c, "Confirm date
lifsk(20) type c, "Header Block
txt30(30) type c, "Order User Status Description
lifsp(20) type c, "Line Block
dispo(20) type c, "MRP Controller
dsnam(20) type c, "MRP Controller Description
vmsta(20) type c, "Material Sales Status
kunnr(20) type c, "Sold To
cname(35) type c, "Sold To Name
regio(20) type c, "State
cufd(10) type c, "CUD
bstnk(20) type c, "PO#
bsark(20) type c, "Ordering Method
matnr(20) type c, "Material
maktx(35) type c, "Material Description
t200(20) type c, "T200
vtext(20) type c, "T200 Description
matkl(20) type c, "Material Group
zzbomind(7) type c, "BOM Indicator
ostat(20) type c, "Order Status
cmgst(20) type c, "CRD
inco1(20) type c, "Incoterms
oqty(20) type c, "Order Quantity
pqty(20) type c, "Open Quantity
unit(20) type c, "UOM
onet(20) type c, "Order Value
pnet(20) type c, "Open Value
curr(20) type c, "Currency key
so_bezei like tvkbt-bezei,"Sales Office
sg_bezei like tvgrt-bezei,"Sales Group
bname(20) type c, "Ordering Party
contact(20) type c, "Contact Name
telf1(20) type c, "Contact telf1
reqqty(20) type c, "Item Request qty
reqval(20) type c, "Item Request value
conqty(20) type c, "Item Confirm qty
conval(20) type c, "Item Confirm value
zzrev(02) type c, "Revenue recognition acceptance
bezei(20) type c, "Revenue recognition text
vgbel(20) type c, "Reference Order for RETURNS
0008text(255) type c, "Internal Order Comment Text
end of t_excel.
data: t_excel_bckord like t_excel occurs 0 with header line,
t_excel_bcklog like t_excel occurs 0 with header line,
t_excel_blkord like t_excel occurs 0 with header line.
types: data1(1500) type c,
ty type table of data1.
data: it type ty with header line,
it_2 type ty with header line,
it_3 type ty with header line,
rec type sy-tfill,
deli(1) type c,
l_amt(18) type c.
data: begin of hex,
tab type x,
end of hex.
field-symbols: <fs> .
constants cns_09(2) type n value 09.
assign deli to <fs> type 'X'.
hex-tab = cns_09.
<fs> = hex-tab.
data gv_sheet_name(20) type c .
M A C R O Declaration
define ole_check_error.
if &1 ne 0.
message e001(zz) with &1.
exit.
endif.
end-of-definition.
t_excel_bckord-vkorg = 'ABC'.
t_excel_bckord-vbtyp = 'DEF'.
t_excel_bckord-auart = 'GHI'.
t_excel_bckord-ernam = 'JKL'.
t_excel_bckord-vbeln = 'MNO'.
t_excel_bckord-0008text = 'XYZ'.
append t_excel_bckord.
t_excel_bckord-vkorg = 'ABC1'.
t_excel_bckord-vbtyp = 'DEF1'.
t_excel_bckord-auart = 'GHI1'.
t_excel_bckord-ernam = 'JKL1'.
t_excel_bckord-vbeln = 'MNO1'.
t_excel_bckord-0008text = 'XYZ1'.
append t_excel_bckord.
t_excel_bckord-vkorg = 'ABC2'.
t_excel_bckord-vbtyp = 'DEF2'.
t_excel_bckord-auart = 'GHI2'.
t_excel_bckord-ernam = 'JKL2'.
t_excel_bckord-vbeln = 'MNO2'.
t_excel_bckord-0008text = 'XYZ2'.
append t_excel_bckord.
t_excel_bcklog-vkorg = 'ABC'.
t_excel_bcklog-vbtyp = 'DEF'.
t_excel_bcklog-auart = 'GHI'.
t_excel_bcklog-ernam = 'JKL'.
t_excel_bcklog-vbeln = 'MNO'.
t_excel_bcklog-0008text = 'XYZ'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC1'.
t_excel_bcklog-vbtyp = 'DEF1'.
t_excel_bcklog-auart = 'GHI1'.
t_excel_bcklog-ernam = 'JKL1'.
t_excel_bcklog-vbeln = 'MNO1'.
t_excel_bcklog-0008text = 'XYZ1'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC2'.
t_excel_bcklog-vbtyp = 'DEF2'.
t_excel_bcklog-auart = 'GHI2'.
t_excel_bcklog-ernam = 'JKL2'.
t_excel_bcklog-vbeln = 'MNO2'.
t_excel_bcklog-0008text = 'XYZ2'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC3'.
t_excel_bcklog-vbtyp = 'DEF3'..
t_excel_bcklog-auart = 'GHI3'.
t_excel_bcklog-ernam = 'JKL3'.
t_excel_bcklog-vbeln = 'MNO3'.
t_excel_bcklog-0008text = 'XYZ3'.
append t_excel_bcklog.
t_excel_blkord-vkorg = 'ABC'.
t_excel_blkord-vbtyp = 'DEF'.
t_excel_blkord-auart = 'GHI'.
t_excel_blkord-ernam = 'JKL'.
t_excel_blkord-vbeln = 'MNO'.
t_excel_blkord-0008text = 'XYZ'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC1'.
t_excel_blkord-vbtyp = 'DEF1'.
t_excel_blkord-auart = 'GHI1'.
t_excel_blkord-ernam = 'JKL1'.
t_excel_blkord-vbeln = 'MNO1'.
t_excel_blkord-0008text = 'XYZ1'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC2'.
t_excel_blkord-vbtyp = 'DEF2'.
t_excel_blkord-auart = 'GHI2'.
t_excel_blkord-ernam = 'JKL2'.
t_excel_blkord-vbeln = 'MNO2'.
t_excel_blkord-0008text = 'XYZ2'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC3'.
t_excel_blkord-vbtyp = 'DEF3'..
t_excel_blkord-auart = 'GHI3'.
t_excel_blkord-ernam = 'JKL3'.
t_excel_blkord-vbeln = 'MNO3'.
t_excel_blkord-0008text = 'XYZ3'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC4'.
t_excel_blkord-vbtyp = 'DEF4'..
t_excel_blkord-auart = 'GHI4'.
t_excel_blkord-ernam = 'JKL4'.
t_excel_blkord-vbeln = 'MNO4'.
t_excel_blkord-0008text = 'XYZ4'.
append t_excel_blkord.
loop at t_excel_bckord.
concatenate
t_excel_bckord-vkorg
t_excel_bckord-vbtyp
t_excel_bckord-auart
t_excel_bckord-ernam
t_excel_bckord-vbeln
t_excel_bckord-posnr
t_excel_bckord-erdat
t_excel_bckord-vdatu
t_excel_bckord-reqdat
t_excel_bckord-condat
t_excel_bckord-lifsk
t_excel_bckord-txt30
t_excel_bckord-lifsp
t_excel_bckord-dispo
t_excel_bckord-dsnam
t_excel_bckord-vmsta
t_excel_bckord-kunnr
t_excel_bckord-cname
t_excel_bckord-regio
t_excel_bckord-cufd
t_excel_bckord-bstnk
t_excel_bckord-bsark
t_excel_bckord-matnr
t_excel_bckord-maktx
t_excel_bckord-t200
t_excel_bckord-vtext
t_excel_bckord-matkl
t_excel_bckord-zzbomind
t_excel_bckord-ostat
t_excel_bckord-cmgst
t_excel_bckord-inco1
t_excel_bckord-oqty
t_excel_bckord-pqty
t_excel_bckord-unit
t_excel_bckord-onet
t_excel_bckord-pnet
t_excel_bckord-curr
t_excel_bckord-so_bezei
t_excel_bckord-sg_bezei
t_excel_bckord-bname
t_excel_bckord-contact
t_excel_bckord-telf1
t_excel_bckord-reqqty
t_excel_bckord-reqval
t_excel_bckord-conqty
t_excel_bckord-conval
t_excel_bckord-zzrev
t_excel_bckord-bezei
t_excel_bckord-vgbel
t_excel_bckord-0008text
into it
separated by deli.
append it.
clear it.
endloop.
loop at t_excel_bcklog.
concatenate
t_excel_bcklog-vkorg
t_excel_bcklog-vbtyp
t_excel_bcklog-auart
t_excel_bcklog-ernam
t_excel_bcklog-vbeln
t_excel_bcklog-posnr
t_excel_bcklog-erdat
t_excel_bcklog-vdatu
t_excel_bcklog-reqdat
t_excel_bcklog-condat
t_excel_bcklog-lifsk
t_excel_bcklog-txt30
t_excel_bcklog-lifsp
t_excel_bcklog-dispo
t_excel_bcklog-dsnam
t_excel_bcklog-vmsta
t_excel_bcklog-kunnr
t_excel_bcklog-cname
t_excel_bcklog-regio
t_excel_bcklog-cufd
t_excel_bcklog-bstnk
t_excel_bcklog-bsark
t_excel_bcklog-matnr
t_excel_bcklog-maktx
t_excel_bcklog-t200
t_excel_bcklog-vtext
t_excel_bcklog-matkl
t_excel_bcklog-zzbomind
t_excel_bcklog-ostat
t_excel_bcklog-cmgst
t_excel_bcklog-inco1
t_excel_bcklog-oqty
t_excel_bcklog-pqty
t_excel_bcklog-unit
t_excel_bcklog-onet
t_excel_bcklog-pnet
t_excel_bcklog-curr
t_excel_bcklog-so_bezei
t_excel_bcklog-sg_bezei
t_excel_bcklog-bname
t_excel_bcklog-contact
t_excel_bcklog-telf1
t_excel_bcklog-reqqty
t_excel_bcklog-reqval
t_excel_bcklog-conqty
t_excel_bcklog-conval
t_excel_bcklog-zzrev
t_excel_bcklog-bezei
t_excel_bcklog-vgbel
t_excel_bcklog-0008text
into it_2
separated by deli.
append it_2.
clear it_2.
endloop.
loop at t_excel_blkord.
concatenate
t_excel_blkord-vkorg
t_excel_blkord-vbtyp
t_excel_blkord-auart
t_excel_blkord-ernam
t_excel_blkord-vbeln
t_excel_blkord-posnr
t_excel_blkord-erdat
t_excel_blkord-vdatu
t_excel_blkord-reqdat
t_excel_blkord-condat
t_excel_blkord-lifsk
t_excel_blkord-txt30
t_excel_blkord-lifsp
t_excel_blkord-dispo
t_excel_blkord-dsnam
t_excel_blkord-vmsta
t_excel_blkord-kunnr
t_excel_blkord-cname
t_excel_blkord-regio
t_excel_blkord-cufd
t_excel_blkord-bstnk
t_excel_blkord-bsark
t_excel_blkord-matnr
t_excel_blkord-maktx
t_excel_blkord-t200
t_excel_blkord-vtext
t_excel_blkord-matkl
t_excel_blkord-zzbomind
t_excel_blkord-ostat
t_excel_blkord-cmgst
t_excel_blkord-inco1
t_excel_blkord-oqty
t_excel_blkord-pqty
t_excel_blkord-unit
t_excel_blkord-onet
t_excel_blkord-pnet
t_excel_blkord-curr
t_excel_blkord-so_bezei
t_excel_blkord-sg_bezei
t_excel_blkord-bname
t_excel_blkord-contact
t_excel_blkord-telf1
t_excel_blkord-reqqty
t_excel_blkord-reqval
t_excel_blkord-conqty
t_excel_blkord-conval
t_excel_blkord-zzrev
t_excel_blkord-bezei
t_excel_blkord-vgbel
t_excel_blkord-0008text
into it_3
separated by deli.
append it_3.
clear it_3.
endloop.
if h_excel-header = space or h_excel-handle = -1.
start Excel
create object h_excel 'EXCEL.APPLICATION'.
endif.
PERFORM err_hdl.
*--- get list of workbooks, initially empty
call method of h_excel 'Workbooks' = h_mapl.
PERFORM err_hdl.
set property of h_excel 'Visible' = 1.
add a new workbook
call method of h_mapl 'Add' = h_map.
PERFORM err_hdl.
*GV_SHEET_NAME = '1st SHEET'.
gv_sheet_name = 'Back Orders'.
get property of h_excel 'ACTIVESHEET' = worksheet.
set property of worksheet 'Name' = gv_sheet_name .
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
data l_rc type i.
call method cl_gui_frontend_services=>clipboard_export
importing
data = it[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
PERFORM err_hdl.
call method of worksheet 'Paste'.
PERFORM err_hdl.
CALL METHOD OF h_excel 'QUIT'.
*GV_SHEET_NAME = '2ND SHEET'.
gv_sheet_name = 'Backlog'.
get property of h_excel 'Sheets' = h_sheet2 .
call method of h_sheet2 'Add' = h_map.
set property of h_map 'Name' = gv_sheet_name .
get property of h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
call method cl_gui_frontend_services=>clipboard_export
importing
data = it_2[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
PERFORM err_hdl.
call method of worksheet 'Paste'.
*GV_SHEET_NAME = '3rd SHEET'.
gv_sheet_name = 'Blocked Orders'.
get property of h_excel 'Sheets' = h_sheet3 .
call method of h_sheet3 'Add' = h_map.
set property of h_map 'Name' = gv_sheet_name .
get property of h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
call method cl_gui_frontend_services=>clipboard_export
importing
data = it_3[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
PERFORM err_hdl.
call method of worksheet 'Paste'.
*--- disconnect from Excel
free object h_zl.
free object h_mapl.
free object h_map.
free object h_excel.
Similar Messages
-
How to download data in multiple sheets of one excel file
Hello,
I want to download data in multiple sheets of one excel file ..through ole2_object.
i have created program but it is not it is not giving the desird op.
here is the code..
create object excel 'EXCEL.APPLICATION'.
call method of excel 'WORKBOOKS' = books.
call method of books 'ADD' = book1.
*****************" Here we r creating the first sheet.
if flag1 = 'X'.
call method of book1 'WORKSHEETS' = SHEET
EXPORTING
#1 = 1. " here 1 indicating the position of sheet means first position.
call method of sheet 'Activate'.
set property of sheet 'Name' = 'Developments_Summary_Report'.
perform excel_fill.
endif.
*****************" Here we r creating the second sheet.
if flag2 = 'X'.
call method of book1 'WORKSHEETS' = SHEET
EXPORTING
#1 = 2. " here 2 indicating the position of sheet means second position.
call method of sheet 'Activate'.
set property of sheet 'Name' = 'BDC_Developments_Report'.
perform excel_fill.
endif.
set property of excel 'VISIBLE' = 1. " due to this property excel window is visible.
call method of excel 'QUIT'.
but it is generating the two different excel file ..
Thanks in advance,
Paresh.Hi,
Copy and paste this code in your SAP
*& Report ZETA_EXCEL_DOWNLOAD_CLIPBOARD *
report zeta_excel_download_clipboard .
include ole2incl.
data: w_cell1 type ole2_object,
w_cell2 type ole2_object.
*--- Ole data Declarations
data: h_excel type ole2_object, " Excel object
h_mapl type ole2_object, " list of workbooks
h_map type ole2_object, " workbook
h_zl type ole2_object, " cell
h_f type ole2_object, " font
gs_interior type ole2_object, " Pattern
worksheet type ole2_object,
h_cell type ole2_object,
h_cell1 type ole2_object,
range type ole2_object,
h_sheet2 type ole2_object,
h_sheet3 type ole2_object,
gs_font type ole2_object,
flg_stop(1) type c.
** Internal table Declaration
data: begin of t_excel occurs 0,
vkorg(20) type c, "Sales Org
vbtyp(20) type c, "Document Category
auart(20) type c, "Document Type
ernam(20) type c, "Created By
vbeln(20) type c, "Document Number
posnr(20) type c, "Item Number
erdat(20) type c, "Created Date
vdatu(20) type c, "Header Requested Delivery Date
reqdat(20) type c, "Request date
condat(20) type c, "Confirm date
lifsk(20) type c, "Header Block
txt30(30) type c, "Order User Status Description
lifsp(20) type c, "Line Block
dispo(20) type c, "MRP Controller
dsnam(20) type c, "MRP Controller Description
vmsta(20) type c, "Material Sales Status
kunnr(20) type c, "Sold To
cname(35) type c, "Sold To Name
regio(20) type c, "State
cufd(10) type c, "CUD
bstnk(20) type c, "PO#
bsark(20) type c, "Ordering Method
matnr(20) type c, "Material
maktx(35) type c, "Material Description
t200(20) type c, "T200
vtext(20) type c, "T200 Description
matkl(20) type c, "Material Group
zzbomind(7) type c, "BOM Indicator
ostat(20) type c, "Order Status
cmgst(20) type c, "CRD
inco1(20) type c, "Incoterms
oqty(20) type c, "Order Quantity
pqty(20) type c, "Open Quantity
unit(20) type c, "UOM
onet(20) type c, "Order Value
pnet(20) type c, "Open Value
curr(20) type c, "Currency key
so_bezei like tvkbt-bezei,"Sales Office
sg_bezei like tvgrt-bezei,"Sales Group
bname(20) type c, "Ordering Party
contact(20) type c, "Contact Name
telf1(20) type c, "Contact telf1
reqqty(20) type c, "Item Request qty
reqval(20) type c, "Item Request value
conqty(20) type c, "Item Confirm qty
conval(20) type c, "Item Confirm value
zzrev(02) type c, "Revenue recognition acceptance
bezei(20) type c, "Revenue recognition text
vgbel(20) type c, "Reference Order for RETURNS
0008text(255) type c, "Internal Order Comment Text
end of t_excel.
data: t_excel_bckord like t_excel occurs 0 with header line,
t_excel_bcklog like t_excel occurs 0 with header line,
t_excel_blkord like t_excel occurs 0 with header line.
types: data1(1500) type c,
ty type table of data1.
data: it type ty with header line,
it_2 type ty with header line,
it_3 type ty with header line,
rec type sy-tfill,
deli(1) type c,
l_amt(18) type c.
data: begin of hex,
tab type x,
end of hex.
field-symbols: <fs> .
constants cns_09(2) type n value 09.
assign deli to <fs> type 'X'.
hex-tab = cns_09.
<fs> = hex-tab.
data gv_sheet_name(20) type c .
* M A C R O Declaration
define ole_check_error.
if &1 ne 0.
message e001(zz) with &1.
exit.
endif.
end-of-definition.
t_excel_bckord-vkorg = 'ABC'.
t_excel_bckord-vbtyp = 'DEF'.
t_excel_bckord-auart = 'GHI'.
t_excel_bckord-ernam = 'JKL'.
t_excel_bckord-vbeln = 'MNO'.
t_excel_bckord-0008text = 'XYZ'.
append t_excel_bckord.
t_excel_bckord-vkorg = 'ABC1'.
t_excel_bckord-vbtyp = 'DEF1'.
t_excel_bckord-auart = 'GHI1'.
t_excel_bckord-ernam = 'JKL1'.
t_excel_bckord-vbeln = 'MNO1'.
t_excel_bckord-0008text = 'XYZ1'.
append t_excel_bckord.
t_excel_bckord-vkorg = 'ABC2'.
t_excel_bckord-vbtyp = 'DEF2'.
t_excel_bckord-auart = 'GHI2'.
t_excel_bckord-ernam = 'JKL2'.
t_excel_bckord-vbeln = 'MNO2'.
t_excel_bckord-0008text = 'XYZ2'.
append t_excel_bckord.
t_excel_bcklog-vkorg = 'ABC'.
t_excel_bcklog-vbtyp = 'DEF'.
t_excel_bcklog-auart = 'GHI'.
t_excel_bcklog-ernam = 'JKL'.
t_excel_bcklog-vbeln = 'MNO'.
t_excel_bcklog-0008text = 'XYZ'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC1'.
t_excel_bcklog-vbtyp = 'DEF1'.
t_excel_bcklog-auart = 'GHI1'.
t_excel_bcklog-ernam = 'JKL1'.
t_excel_bcklog-vbeln = 'MNO1'.
t_excel_bcklog-0008text = 'XYZ1'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC2'.
t_excel_bcklog-vbtyp = 'DEF2'.
t_excel_bcklog-auart = 'GHI2'.
t_excel_bcklog-ernam = 'JKL2'.
t_excel_bcklog-vbeln = 'MNO2'.
t_excel_bcklog-0008text = 'XYZ2'.
append t_excel_bcklog.
t_excel_bcklog-vkorg = 'ABC3'.
t_excel_bcklog-vbtyp = 'DEF3'..
t_excel_bcklog-auart = 'GHI3'.
t_excel_bcklog-ernam = 'JKL3'.
t_excel_bcklog-vbeln = 'MNO3'.
t_excel_bcklog-0008text = 'XYZ3'.
append t_excel_bcklog.
t_excel_blkord-vkorg = 'ABC'.
t_excel_blkord-vbtyp = 'DEF'.
t_excel_blkord-auart = 'GHI'.
t_excel_blkord-ernam = 'JKL'.
t_excel_blkord-vbeln = 'MNO'.
t_excel_blkord-0008text = 'XYZ'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC1'.
t_excel_blkord-vbtyp = 'DEF1'.
t_excel_blkord-auart = 'GHI1'.
t_excel_blkord-ernam = 'JKL1'.
t_excel_blkord-vbeln = 'MNO1'.
t_excel_blkord-0008text = 'XYZ1'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC2'.
t_excel_blkord-vbtyp = 'DEF2'.
t_excel_blkord-auart = 'GHI2'.
t_excel_blkord-ernam = 'JKL2'.
t_excel_blkord-vbeln = 'MNO2'.
t_excel_blkord-0008text = 'XYZ2'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC3'.
t_excel_blkord-vbtyp = 'DEF3'..
t_excel_blkord-auart = 'GHI3'.
t_excel_blkord-ernam = 'JKL3'.
t_excel_blkord-vbeln = 'MNO3'.
t_excel_blkord-0008text = 'XYZ3'.
append t_excel_blkord.
t_excel_blkord-vkorg = 'ABC4'.
t_excel_blkord-vbtyp = 'DEF4'..
t_excel_blkord-auart = 'GHI4'.
t_excel_blkord-ernam = 'JKL4'.
t_excel_blkord-vbeln = 'MNO4'.
t_excel_blkord-0008text = 'XYZ4'.
append t_excel_blkord.
loop at t_excel_bckord.
concatenate
t_excel_bckord-vkorg
t_excel_bckord-vbtyp
t_excel_bckord-auart
t_excel_bckord-ernam
t_excel_bckord-vbeln
t_excel_bckord-posnr
t_excel_bckord-erdat
t_excel_bckord-vdatu
t_excel_bckord-reqdat
t_excel_bckord-condat
t_excel_bckord-lifsk
t_excel_bckord-txt30
t_excel_bckord-lifsp
t_excel_bckord-dispo
t_excel_bckord-dsnam
t_excel_bckord-vmsta
t_excel_bckord-kunnr
t_excel_bckord-cname
t_excel_bckord-regio
t_excel_bckord-cufd
t_excel_bckord-bstnk
t_excel_bckord-bsark
t_excel_bckord-matnr
t_excel_bckord-maktx
t_excel_bckord-t200
t_excel_bckord-vtext
t_excel_bckord-matkl
t_excel_bckord-zzbomind
t_excel_bckord-ostat
t_excel_bckord-cmgst
t_excel_bckord-inco1
t_excel_bckord-oqty
t_excel_bckord-pqty
t_excel_bckord-unit
t_excel_bckord-onet
t_excel_bckord-pnet
t_excel_bckord-curr
t_excel_bckord-so_bezei
t_excel_bckord-sg_bezei
t_excel_bckord-bname
t_excel_bckord-contact
t_excel_bckord-telf1
t_excel_bckord-reqqty
t_excel_bckord-reqval
t_excel_bckord-conqty
t_excel_bckord-conval
t_excel_bckord-zzrev
t_excel_bckord-bezei
t_excel_bckord-vgbel
t_excel_bckord-0008text
into it
separated by deli.
append it.
clear it.
endloop.
loop at t_excel_bcklog.
concatenate
t_excel_bcklog-vkorg
t_excel_bcklog-vbtyp
t_excel_bcklog-auart
t_excel_bcklog-ernam
t_excel_bcklog-vbeln
t_excel_bcklog-posnr
t_excel_bcklog-erdat
t_excel_bcklog-vdatu
t_excel_bcklog-reqdat
t_excel_bcklog-condat
t_excel_bcklog-lifsk
t_excel_bcklog-txt30
t_excel_bcklog-lifsp
t_excel_bcklog-dispo
t_excel_bcklog-dsnam
t_excel_bcklog-vmsta
t_excel_bcklog-kunnr
t_excel_bcklog-cname
t_excel_bcklog-regio
t_excel_bcklog-cufd
t_excel_bcklog-bstnk
t_excel_bcklog-bsark
t_excel_bcklog-matnr
t_excel_bcklog-maktx
t_excel_bcklog-t200
t_excel_bcklog-vtext
t_excel_bcklog-matkl
t_excel_bcklog-zzbomind
t_excel_bcklog-ostat
t_excel_bcklog-cmgst
t_excel_bcklog-inco1
t_excel_bcklog-oqty
t_excel_bcklog-pqty
t_excel_bcklog-unit
t_excel_bcklog-onet
t_excel_bcklog-pnet
t_excel_bcklog-curr
t_excel_bcklog-so_bezei
t_excel_bcklog-sg_bezei
t_excel_bcklog-bname
t_excel_bcklog-contact
t_excel_bcklog-telf1
t_excel_bcklog-reqqty
t_excel_bcklog-reqval
t_excel_bcklog-conqty
t_excel_bcklog-conval
t_excel_bcklog-zzrev
t_excel_bcklog-bezei
t_excel_bcklog-vgbel
t_excel_bcklog-0008text
into it_2
separated by deli.
append it_2.
clear it_2.
endloop.
loop at t_excel_blkord.
concatenate
t_excel_blkord-vkorg
t_excel_blkord-vbtyp
t_excel_blkord-auart
t_excel_blkord-ernam
t_excel_blkord-vbeln
t_excel_blkord-posnr
t_excel_blkord-erdat
t_excel_blkord-vdatu
t_excel_blkord-reqdat
t_excel_blkord-condat
t_excel_blkord-lifsk
t_excel_blkord-txt30
t_excel_blkord-lifsp
t_excel_blkord-dispo
t_excel_blkord-dsnam
t_excel_blkord-vmsta
t_excel_blkord-kunnr
t_excel_blkord-cname
t_excel_blkord-regio
t_excel_blkord-cufd
t_excel_blkord-bstnk
t_excel_blkord-bsark
t_excel_blkord-matnr
t_excel_blkord-maktx
t_excel_blkord-t200
t_excel_blkord-vtext
t_excel_blkord-matkl
t_excel_blkord-zzbomind
t_excel_blkord-ostat
t_excel_blkord-cmgst
t_excel_blkord-inco1
t_excel_blkord-oqty
t_excel_blkord-pqty
t_excel_blkord-unit
t_excel_blkord-onet
t_excel_blkord-pnet
t_excel_blkord-curr
t_excel_blkord-so_bezei
t_excel_blkord-sg_bezei
t_excel_blkord-bname
t_excel_blkord-contact
t_excel_blkord-telf1
t_excel_blkord-reqqty
t_excel_blkord-reqval
t_excel_blkord-conqty
t_excel_blkord-conval
t_excel_blkord-zzrev
t_excel_blkord-bezei
t_excel_blkord-vgbel
t_excel_blkord-0008text
into it_3
separated by deli.
append it_3.
clear it_3.
endloop.
if h_excel-header = space or h_excel-handle = -1.
* start Excel
create object h_excel 'EXCEL.APPLICATION'.
endif.
* PERFORM err_hdl.
*--- get list of workbooks, initially empty
call method of h_excel 'Workbooks' = h_mapl.
* PERFORM err_hdl.
set property of h_excel 'Visible' = 1.
* add a new workbook
call method of h_mapl 'Add' = h_map.
* PERFORM err_hdl.
*GV_SHEET_NAME = '1st SHEET'.
gv_sheet_name = 'Back Orders'.
get property of h_excel 'ACTIVESHEET' = worksheet.
set property of worksheet 'Name' = gv_sheet_name .
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
*CALL METHOD OF gs_cells 'Select' .
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
data l_rc type i.
call method cl_gui_frontend_services=>clipboard_export
importing
data = it[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
* PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
* PERFORM err_hdl.
call method of worksheet 'Paste'.
* PERFORM err_hdl.
* CALL METHOD OF h_excel 'QUIT'.
*GV_SHEET_NAME = '2ND SHEET'.
gv_sheet_name = 'Backlog'.
get property of h_excel 'Sheets' = h_sheet2 .
call method of h_sheet2 'Add' = h_map.
set property of h_map 'Name' = gv_sheet_name .
get property of h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
call method cl_gui_frontend_services=>clipboard_export
importing
data = it_2[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
* PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
* PERFORM err_hdl.
call method of worksheet 'Paste'.
*GV_SHEET_NAME = '3rd SHEET'.
gv_sheet_name = 'Blocked Orders'.
get property of h_excel 'Sheets' = h_sheet3 .
call method of h_sheet3 'Add' = h_map.
set property of h_map 'Name' = gv_sheet_name .
get property of h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 50.
call method of h_excel 'Range' = h_cell
exporting
#1 = w_cell1
#2 = w_cell2.
get property of h_cell 'Font' = gs_font .
set property of gs_font 'Bold' = 1 .
call method cl_gui_frontend_services=>clipboard_export
importing
data = it_3[]
changing
rc = l_rc
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
call method of h_excel 'Cells' = w_cell1
exporting
#1 = 1
#2 = 1.
call method of h_excel 'Cells' = w_cell2
exporting
#1 = 1
#2 = 1.
* PERFORM err_hdl.
call method of h_excel 'Range' = range
exporting
#1 = w_cell1
#2 = w_cell2.
call method of range 'Select'.
* PERFORM err_hdl.
call method of worksheet 'Paste'.
*--- disconnect from Excel
free object h_zl.
free object h_mapl.
free object h_map.
free object h_excel.
Regards
Sudheer -
I have a Macbook Air. I have MS office installed and work in Excel often with no issues. But When I download an excel spread sheet from a Ford web site I seem to be getting code and not the work sheet.
Example-
MIME-Version: 1.0
X-Document-Type: Workbook
Content-Type: multipart/related; boundary="====Boundary===="
--====Boundary====
Content-Location: file:///C:/HOLD.XHT
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset="utf-8"
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<HEAD>
<meta name="Excel Workbook Frameset">
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>BTB</x:Name>
<x:WorksheetSource HRef="./IBIT0001.xht"/>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>GSM</x:Name>
<x:WorksheetSource HRef="./IBIT0002.xht"/>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>RODetail</x:Name>
<x:WorksheetSource HRef="./IBIT0003.xht"/>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</HEAD>
</HTML>
--====Boundary====
Content-Location: file:///C:/IBIT0001.xht
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset="utf-8"
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<style>
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:1.0in .75in 1.0in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-page-orientation:landscape;}
tr
{mso-height-source:auto;}
col
{mso-width-source:auto;}
br
{mso-data-placement:same-cell;}
.style21
{color:blue;
font-size:10.0pt;
font-weight:400;
font-style:normal;
text-decoration:underline;
text-underline-style:single;
font-family:Arial;Try search/ask in the forum devoted entirely to Excel issues:
http://answers.microsoft.com/en-us/mac/forum/macexcel -
How to subscribe the report into one excel multiple sheets in ssrs
Hi Team,
I have a requirement where i pull my report in one excel with multiple sheets,
1.I have a Emp_Report where i could subscribe my report into excel format,but here i want to subscribe this into multiple sheets in one excel form.
2.Is it possible to subscribe the two reports in one excel with mulitiple sheets.i need this also.
please guide me hw we can achive me ,so that i can start working on that .
am using sql server 2008R2 sql server edition.
pls help me out for thisHi Ychinnari,
According to your description, you want to perform subscription for one report or two reports into multiple sheets within a Excel file.
In Reporting Services, when we add a page break within the report, those pages will be exported into separated sheets in Excel.
For first requirement, subscribe one report into multiple sheets in one Excel file. We can add a page break within a group, then the report will display on multiple sheets when subscribe into Excel format.
For second requirement, subscribe one report into multiple sheets in one Excel file. You can add one report as a subreport into the main report, then add pagebreak between main report and subreport.
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
Hi
I can upload a single worksheet from Excel into an internal table in SAP, but need to upload from complex excel worksheets ie. from multiple named tabs in Excel. Is this possible, and if so, please can you help and advise me how?
Many thanks
SunniHi,
I have done the same requirement of uploading from multiple sheets of a excel file into internal tables recently. Here is what I have done....
1. save the excel sheet as XML file.
2. use XML class (IF_IXML) and its corresponding methods to read the data.
This method is little complex as it requires a fair amount of knowledge in ABAP Objects.
Kamal -
Excel multiple sheet export on job schedule
Is it possible to create a bqy job which emails an excel document with multiple sheets?
Our environment is v11.1.1.1.2, Linux x86
Thanks in advance!Hello,
You can have a schedule a BQY in such a way that it can email the section you want in excel format. But i dont think so its possible for excel with multiple sheets.
Thanks,
BHANU -
How do I download microsoft excell spread sheets?
What Apple program must I purchase in order to doenload excessl spreadsheet files?
I am able to open any Excel spreadsheets I am sent with Numbers.
Allan -
Data download to multiple sheets in Excel without using OLE
Hi,
Please let me know if it is possible to download data to multiple sheets in excel without using OLE method
I am in SRM system and the OLE methods are not working
Please share some sample code or reference links if any
Thanks
SekharJ
Edited by: SekharJ on Sep 8, 2009 8:43 AMHere is my code
LOOP AT it_final INTO wa_final.
AT FIRST.
l_ixml = cl_ixml=>create( ).
l_document = l_ixml->create_document( ).
l_element_flights = l_document->create_simple_element(
name = 'PO_Details'
parent = l_document ).
ENDAT.
l_element_airline = l_document->create_simple_element(
name = 'PO'
parent = l_element_flights ).
l_value = wa_final-object_id.
l_rc = l_element_airline->set_attribute( name = 'Objectid' value =
l_value ).
l_value = wa_final-description.
l_rc = l_element_airline->set_attribute( name = 'Description' value =
l_value ).
l_value = wa_final-number_int.
l_rc = l_element_airline->set_attribute( name = 'Item' value =
l_value ).
l_value = wa_final-description1.
l_rc = l_element_airline->set_attribute( name = 'Description1' value =
l_value ).
l_value = wa_final-quantity.
l_rc = l_element_airline->set_attribute( name = 'Quantity' value =
l_value ).
l_value = wa_final-capex.
l_rc = l_element_airline->set_attribute( name = 'Capex' value =
l_value ).
l_value = wa_final-ser_num.
l_rc = l_element_airline->set_attribute( name = 'SerialNo' value =
l_value ).
l_value = wa_final-plant.
l_rc = l_element_airline->set_attribute( name = 'Plant' value =
l_value ).
l_value = wa_final-loc.
l_rc = l_element_airline->set_attribute( name = 'Location' value =
l_value ).
l_value = wa_final-bundle.
l_rc = l_element_airline->set_attribute( name = 'Bundle' value =
l_value ).
ENDLOOP.
l_streamfactory = l_ixml->create_stream_factory( ).
l_ostream = l_streamfactory->create_ostream_itable( table =
l_xml_table ).
l_renderer = l_ixml->create_renderer( ostream = l_ostream
document = l_document ).
l_rc = l_renderer->render( ).
l_xml_size = l_ostream->get_num_written_raw( ).
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = 'c:\temp\flights.xlsx'
filetype = 'BIN'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Edited by: SekharJ on Sep 8, 2009 12:04 PM
Edited by: SekharJ on Sep 8, 2009 12:15 PM -
How to download multiple sheets in one excel workbook
Hi All,
I have requirement to download multiple sheets in excel workbook. I had
successfully downloaded multiple sheets in excel. But it was downloaded only in
my desktop. My requirement is user selects the path and i have to download the
data in specified path.
Could you please help me on this?
Thanks in Advance,
Basha Shaik>>My requirement is user selects the path and i have to download the
data in specified path.
For this..use CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = TITLE
DEFAULT_EXTENSION =
DEFAULT_FILE_NAME =
WITH_ENCODING =
FILE_FILTER = '.|.'
INITIAL_DIRECTORY =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
FILENAME = W_FNAME
PATH = W_FILEPATH
FULLPATH = W_FULLPATH
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF NOT W_FULLPATH IS INITIAL.
FILE_NAME = W_FULLPATH.
ENDIF.
regards,
priya. -
Download to multiple sheet excel in the background
Hi,
I am trying to download data into multiple excel sheets in the background. I was able to create comma delimited csv file in the server, which can be opened as excel file. This is good when it does not have more that one worksheets.
I have three internal table and to send these internal tables in different worksheets in the same excel file.
Is it possible to have multiple sheets excel file from the csv file?
Thanks,
LokmanHi Lokman,
<b>1</b>.
Yes it is Possible.
<b>2</b>.
Am sending one example program .That is clear to understand .
REPORT zvenkat_head MESSAGE-ID zvenkat .
INCLUDE ole2incl. " Include for OLE object
DATA: application TYPE ole2_object,
workbook TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object,
h_f TYPE ole2_object. " font
*Structure for users deleted
DATA: BEGIN OF itab_yb001_udel OCCURS 0,
bname LIKE yb001-bname,
name_text LIKE addr3_val-name_text,
END OF itab_yb001_udel.
DATA: BEGIN OF itab_yb001_tadd OCCURS 0.
INCLUDE STRUCTURE yb001.
DATA: name_text LIKE addr3_val-name_text,
ttext LIKE tstct-ttext.
DATA: END OF itab_yb001_tadd.
*Structure for Transactions deleted
DATA: BEGIN OF itab_yb001_tdel OCCURS 0.
INCLUDE STRUCTURE yb001.
DATA: name_text LIKE addr3_val-name_text,
ttext LIKE tstct-ttext.
DATA: END OF itab_yb001_tdel.
DATA: BEGIN OF itab_yb001_uadd OCCURS 0,
bname LIKE yb001-bname,
name_text LIKE addr3_val-name_text,
END OF itab_yb001_uadd.
PARAMETERS: p_fname LIKE rlgrap-filename. " File name to download
PERFORM download_file.
FORM - DOWNLOAD_FILE
FORM download_file.
DATA index TYPE i.
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 0.
CALL METHOD OF application 'Workbooks' = workbook.
CALL METHOD OF workbook 'Add'.
CALL METHOD OF application 'Worksheets' = sheet.
CALL METHOD OF sheet 'Add'.
Create 1 Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 1.
SET PROPERTY OF sheet 'Name' = 'Transactions Added'.
CALL METHOD OF sheet 'Activate'.
PERFORM f_xl_theader.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = text-m03
EXCEPTIONS
OTHERS = 1.
LOOP AT itab_yb001_tadd.
index = sy-tabix + 1. " 1 - column name
PERFORM fill_cell USING index 1 0 itab_yb001_tadd-bname.
PERFORM fill_cell USING index 2 0 itab_yb001_tadd-tcode.
PERFORM fill_cell USING index 3 0 itab_yb001_tadd-name_text.
PERFORM fill_cell USING index 4 0 itab_yb001_tadd-ttext.
PERFORM fill_cell USING index 5 0 itab_yb001_tadd-agr_name.
ENDLOOP.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = text-m03
EXCEPTIONS
OTHERS = 1.
Create 2 Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 2.
SET PROPERTY OF sheet 'Name' = 'Transactions Deleted'.
CALL METHOD OF sheet 'Activate'.
PERFORM f_xl_theader.
LOOP AT itab_yb001_tdel.
index = sy-tabix + 1. " 1 - column name
PERFORM fill_cell USING index 1 0 itab_yb001_tdel-bname.
PERFORM fill_cell USING index 2 0 itab_yb001_tdel-tcode.
PERFORM fill_cell USING index 3 0 itab_yb001_tdel-name_text.
PERFORM fill_cell USING index 4 0 itab_yb001_tdel-ttext.
PERFORM fill_cell USING index 5 0 itab_yb001_tdel-agr_name.
ENDLOOP.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = text-m04
EXCEPTIONS
OTHERS = 1.
Create 3 Excel Sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 3.
CALL METHOD OF sheet 'Activate'.
SET PROPERTY OF sheet 'Name' = 'Users Added'.
PERFORM f_xl_uheader.
LOOP AT itab_yb001_uadd.
index = sy-tabix + 1. " 1 - column name
PERFORM fill_cell USING index 1 0 itab_yb001_uadd-bname.
PERFORM fill_cell USING index 2 0 itab_yb001_uadd-name_text.
ENDLOOP.
Create 4 Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 4.
SET PROPERTY OF sheet 'Name' = 'Users Deleted'.
CALL METHOD OF sheet 'Activate'.
PERFORM f_xl_uheader.
LOOP AT itab_yb001_udel.
index = sy-tabix + 1. " 1 - column name
PERFORM fill_cell USING index 1 0 itab_yb001_udel-bname.
PERFORM fill_cell USING index 2 0 itab_yb001_udel-name_text.
ENDLOOP.
Save excel speadsheet to particular filename
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = p_fname "filename
#2 = 1. "fileFormat
PERFORM err_hdl.
Closes excel window, data is lost if not saved
SET PROPERTY OF application 'visible' = 0.
Close the file
CALL METHOD OF workbook 'CLOSE'.
Quit the file
CALL METHOD OF application 'QUIT'.
FREE OBJECT application.
ENDFORM. "DOWNLOAD_FILE
*& Form F_XL_THEADER
Header for XL sheet
--> p1 text
<-- p2 text
FORM f_xl_theader .
output column headings to active Excel sheet
PERFORM fill_cell USING 1 1 1 text-t01.
PERFORM fill_cell USING 1 2 1 text-t02.
PERFORM fill_cell USING 1 3 1 text-t03.
PERFORM fill_cell USING 1 4 1 text-t04.
PERFORM fill_cell USING 1 5 1 text-t05.
ENDFORM. " F_XL_THEADER
FORM FILL_CELL *
sets cell at coordinates i,j to value val boldtype bold *
FORM fill_cell USING i j bold val.
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = i #2 = j.
PERFORM err_hdl.
SET PROPERTY OF cells 'Value' = val .
PERFORM err_hdl.
GET PROPERTY OF cells 'Font' = h_f.
PERFORM err_hdl.
SET PROPERTY OF h_f 'Bold' = bold .
PERFORM err_hdl.
ENDFORM. "FILL_CELL
outputs OLE error if any *
--> p1 text
<-- p2 text
FORM err_hdl.
IF sy-subrc <> 0.
WRITE: / 'Fehler bei OLE-Automation:'(010), sy-subrc.
STOP.
ENDIF.
ENDFORM. " ERR_HDL
Header for XL sheet
--> p1 text
<-- p2 text
FORM f_xl_uheader .
PERFORM fill_cell USING 1 1 1 text-t01.
PERFORM fill_cell USING 1 2 1 text-t03.
ENDFORM. " F_XL_UHEADER
Please try to understand first and replicate to ur requirement.
Please let me know if u have any problem.
<b>Thanks,
Venkat.O</b> -
Downloading data into multiple work sheets in excel
Hi All,
Could you please tell me the way of downloading data into multiple work sheets .
Now, we are downloading data into multiple excel files and after that copying all the excel file data in to different work sheets of the single excel manually.
So , here I want directly download the data into different work sheets of single excel file.
Regards,
Siddivinesh JoguHi,
Down load into three worksheets in one XL
REPORT ZKC_TEST1.
INCLUDE ole2incl.
DATA: w_cell1 TYPE ole2_object,
w_cell2 TYPE ole2_object.
*--- Ole data Declarations
DATA: h_excel TYPE ole2_object, " Excel object
h_mapl TYPE ole2_object, " list of workbooks
h_map TYPE ole2_object, " workbook
h_zl TYPE ole2_object, " cell
h_f TYPE ole2_object, " font
gs_interior TYPE ole2_object, " Pattern
worksheet TYPE ole2_object,
h_cell TYPE ole2_object,
h_cell1 TYPE ole2_object,
range TYPE ole2_object,
h_sheet2 TYPE ole2_object,
h_sheet3 TYPE ole2_object,
gs_font TYPE ole2_object,
e_color TYPE ole2_object,
gs_italic TYPE ole2_object,
flg_stop(1) TYPE c.
** Internal table Declaration
DATA: BEGIN OF t_excel OCCURS 0,
MATNR type mara-matnr, "(18) type c,
ERSDA type mara-ersda, " (8) type c,
ERNAM type mara-ernam, "(12) type c,
LAEDA type mara-laeda, "(8) type c,
AENAM type mara-aenam, "(12) type c,
VPSTA type mara-vpsta, "(15) type c,
PSTAT type mara-pstat, "(15) type c,
END OF t_excel.
DATA: t_excel_bckord LIKE t_excel OCCURS 0 WITH HEADER LINE,
t_excel_bcklog LIKE t_excel OCCURS 0 WITH HEADER LINE,
t_excel_blkord LIKE t_excel OCCURS 0 WITH HEADER LINE.
data: wa_excel_bckord like line of t_excel.
TYPES: data1(1500) TYPE c,
ty TYPE TABLE OF data1.
DATA: it TYPE ty WITH HEADER LINE,
it_2 TYPE ty WITH HEADER LINE,
it_3 TYPE ty WITH HEADER LINE,
rec TYPE sy-tfill,
deli(1) TYPE c,
l_amt(18) TYPE c.
DATA: BEGIN OF hex,
tab TYPE x,
END OF hex.
FIELD-SYMBOLS: <fs> .
CONSTANTS cns_09(2) TYPE n VALUE 09.
ASSIGN deli TO <fs> TYPE 'X'.
hex-tab = cns_09.
<fs> = hex-tab.
DATA gv_sheet_name(20) TYPE c .
*---selecting into tables
select MATNR
ERSDA
ERNAM
LAEDA
AENAM
VPSTA
PSTAT
from mara into table t_excel_bckord
where pstat = 'KVELBCD'.
wa_excel_bckord-matnr = 'MATNR'.
wa_excel_bckord-ersda = 'ERSDA'.
wa_excel_bckord-ernam = 'ERNAM'.
wa_excel_bckord-laeda = 'LAEDA'.
wa_excel_bckord-aenam = 'AENAM'.
wa_excel_bckord-vpsta = 'VPSTA'.
wa_excel_bckord-pstat = 'PSTAT'.
INSERT wa_excel_bckord
INTO t_excel_bckord INDEX 1 .
select MATNR
ERSDA
ERNAM
LAEDA
AENAM
VPSTA
PSTAT
from mara into table t_excel_bcklog
where pstat = 'KVELBCDP'.
INSERT wa_excel_bckord
INTO t_excel_bcklog INDEX 1 .
select MATNR
ERSDA
ERNAM
LAEDA
AENAM
VPSTA
PSTAT
from mara into table t_excel_blkord
where pstat = 'KEBC'.
INSERT wa_excel_bckord
INTO t_excel_blkord INDEX 1 .
LOOP AT t_excel_bckord.
CONCATENATE
t_excel_bckord-MATNR
t_excel_bckord-ERSDA
t_excel_bckord-ERNAM
t_excel_bckord-laeda
t_excel_bckord-aenam
t_excel_bckord-vpsta
t_excel_bckord-pstat
INTO it
SEPARATED BY deli.
APPEND it.
CLEAR it.
ENDLOOP.
LOOP AT t_excel_bcklog.
CONCATENATE
t_excel_bcklog-matnr
t_excel_bcklog-ersda
t_excel_bcklog-ernam
t_excel_bcklog-laeda
t_excel_bcklog-aenam
t_excel_bcklog-vpsta
t_excel_bcklog-pstat
INTO it_2
SEPARATED BY deli.
APPEND it_2.
CLEAR it_2.
ENDLOOP.
LOOP AT t_excel_blkord.
CONCATENATE
t_excel_blkord-matnr
t_excel_blkord-ersda
t_excel_blkord-ernam
t_excel_blkord-laeda
t_excel_blkord-aenam
t_excel_blkord-vpsta
t_excel_blkord-pstat
INTO it_3
SEPARATED BY deli.
APPEND it_3.
CLEAR it_3.
ENDLOOP.
*--- start Excel
IF h_excel-header = space OR h_excel-handle = -1.
CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
ENDIF.
*--- get list of workbooks, initially empty
CALL METHOD OF h_excel 'Workbooks' = h_mapl.
SET PROPERTY OF h_excel 'Visible' = 1.
CALL METHOD OF h_mapl 'Add' = h_map.
gv_sheet_name = 'Back Orders'.
GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
SET PROPERTY OF worksheet 'Name' = gv_sheet_name .
*--Formatting the area of additional data 1 and doing the BOLD
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = 50.
CALL METHOD OF h_excel 'Range' = h_cell
EXPORTING
#1 = w_cell1
#2 = w_cell2.
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
SET PROPERTY OF gs_font 'Name' = 'Arial' .
GET PROPERTY OF h_cell 'Interior' = e_color.
SET PROPERTY OF e_color 'ColorIndex' = 35.
GET PROPERTY OF h_cell 'Font' = gs_italic .
SET PROPERTY OF gs_italic 'Italic' = 1 .
DATA l_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = it[]
CHANGING
rc = l_rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Range' = range
EXPORTING
#1 = w_cell1
#2 = w_cell2.
CALL METHOD OF range 'Select'.
CALL METHOD OF worksheet 'Paste'.
gv_sheet_name = 'Backlog'.
GET PROPERTY OF h_excel 'Sheets' = h_sheet2 .
CALL METHOD OF h_sheet2 'Add' = h_map.
SET PROPERTY OF h_map 'Name' = gv_sheet_name .
GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = 50.
CALL METHOD OF h_excel 'Range' = h_cell
EXPORTING
#1 = w_cell1
#2 = w_cell2.
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
GET PROPERTY OF h_cell 'Interior' = e_color.
SET PROPERTY OF e_color 'ColorIndex' = 40.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = it_2[]
CHANGING
rc = l_rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Range' = range
EXPORTING
#1 = w_cell1
#2 = w_cell2.
CALL METHOD OF range 'Select'.
CALL METHOD OF worksheet 'Paste'.
gv_sheet_name = 'Blocked Orders'.
GET PROPERTY OF h_excel 'Sheets' = h_sheet3 .
CALL METHOD OF h_sheet3 'Add' = h_map.
SET PROPERTY OF h_map 'Name' = gv_sheet_name .
GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
*--Formatting the area of additional data 1 and doing the BOLD
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = 50.
CALL METHOD OF h_excel 'Range' = h_cell
EXPORTING
#1 = w_cell1
#2 = w_cell2.
GET PROPERTY OF h_cell 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
GET PROPERTY OF h_cell 'Interior' = e_color.
SET PROPERTY OF e_color 'ColorIndex' = 45.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = it_3[]
CHANGING
rc = l_rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL METHOD OF h_excel 'Cells' = w_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Cells' = w_cell2
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF h_excel 'Range' = range
EXPORTING
#1 = w_cell1
#2 = w_cell2.
CALL METHOD OF range 'Select'.
CALL METHOD OF worksheet 'Paste'.
*--- disconnect from Excel
FREE OBJECT h_zl.
FREE OBJECT h_mapl.
FREE OBJECT h_map.
FREE OBJECT h_excel.
Thanks,
Krishna.. -
Download data from multiple tabs of ALV to tabs of Excel
Hi,
I have a requirement where ALV is being displayed in 6 tabs. Can a download functionality be provided in such a way that data from all the tabs gets downloaded into multiple sheets of Excel document.
In the attached file, expected output with ALV in multiple tabs is displayed. Are there any Function modules which can be used to download data from ALV in each tab into Excel document sheets in one go?
Thanks,
Tejaswini.This is a FAQ, did you use search tool with keywords like worksheet, activate and OLE to find many threads and (some examples)
a sample like XLSX Upload - A Unified Approach
a project like abap2xlsx
Regards,
Raymond -
how to download data into multiple tab sheets in a single file
report zole123.
INCLUDE ole2incl.
DATA: count TYPE i,
application TYPE ole2_object,
workbook TYPE ole2_object,
excel TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.
DATA: BEGIN OF itab1 OCCURS 0, first_name(10), END OF itab1.
DATA: BEGIN OF itab2 OCCURS 0, last_name(10), END OF itab2.
DATA: BEGIN OF itab3 OCCURS 0, place(50), END OF itab3.
*START-OF-SELECTION
START-OF-SELECTION.
APPEND: 'roshani' TO itab1, 'jain' TO itab2,
'worli' TO itab3,
'nehal' TO itab1, 'shah' TO itab2,
'chowpatty' TO itab3,
'saad' TO itab1, 'sheikh' TO itab2,
'versova' TO itab3,
'sushilnath' TO itab1, 'shukla' TO itab2,
'grant road' TO itab3,
'ajju' TO itab1, 'ratna' TO itab2,
'gaon' TO itab3,
'sanant' TO itab1, 'R.' TO itab2,
'mahim' TO itab3.
* CREATE OBJECT application 'excel.application'.
* SET PROPERTY OF application 'visible' = 1.
* CALL METHOD OF application 'Workbooks' = workbook.
* CALL METHOD OF workbook 'Add'.
CREATE OBJECT excel 'EXCEL.APPLICATION'.
IF sy-subrc NE 0.
WRITE: / 'No EXCEL creation possible'.
STOP.
ENDIF.
SET PROPERTY OF excel 'DisplayAlerts' = 0.
CALL METHOD OF excel 'WORKBOOKS' = workbook .
SET PROPERTY OF excel 'VISIBLE' = 1.
* Create worksheet
SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
CALL METHOD OF workbook 'ADD'.
DO 3 TIMES.
IF sy-index GT 1.
CALL METHOD OF excel 'WORKSHEETS' = sheet.
CALL METHOD OF sheet 'ADD'.
FREE OBJECT sheet.
ENDIF.
ENDDO.
count = 1.
DO 3 TIMES.
CALL METHOD OF excel 'WORKSHEETS' = sheet
EXPORTING
#1 = count.
* perform get_sheet_name using scnt sname.
CASE count.
WHEN '1'.
SET PROPERTY OF sheet 'NAME' = 'firstName'.
CALL METHOD OF sheet 'ACTIVATE'.
itab1-first_name = 'FIRST NAME'.
LOOP AT itab1.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Formula' = itab1-first_name.
SET PROPERTY OF cells 'Value' = itab1-first_name.
ENDLOOP.
WHEN '2'.
SET PROPERTY OF sheet 'NAME' = 'LastName'.
CALL METHOD OF sheet 'ACTIVATE'.
LOOP AT itab2.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Formula' = itab2-last_name.
SET PROPERTY OF cells 'Value' = itab2-last_name.
ENDLOOP.
WHEN '3'.
SET PROPERTY OF sheet 'NAME' = 'place'.
CALL METHOD OF sheet 'ACTIVATE'.
LOOP AT itab3.
index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Formula' = itab3-place.
SET PROPERTY OF cells 'Value' = itab3-place.
ENDLOOP.
ENDCASE.
count = count + 1.
ENDDO.
* Save excel speadsheet to particular filename
GET PROPERTY OF excel 'ActiveSheet' = sheet.
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = 'c:tempexceldoc1.xls' "filename
#2 = 1. "fileFormat -
Excel Template with Multiple Sheets
Hi everyone,
I need to build Excel template with multiple sheets where each sheet should have at-least one chart.
Thanks
AravindHi
Could you please explain those ways here.?
Many Thanks,
BK -
Download to excel sheet from ALV Grid report
Hi,
I need to download 3 lakhs of data to excel sheet but the constraint is that excel is having max limit of 65000 line items.
So i need to know the way in which i can create more than one sheet in excel while downloading so that each sheet can hold upto 65000 line items.
i need to create atleast 6 sheets in excel while downloading from report.
please help.Hi,
While downloading the data, it will prompt you save the list in file - Uncoverted, Spreadsheet, Rich text format, HTML format, Copy to Clipboard.
Why don't you try using Uncoverted format and give extension as .txt file.
So that you can download all 3 lacs of records.
Even if you use any FM, it will indirectly use excel for downloading and it will have restriction of having 65000 records only.
Thanks,
Sriram Ponna.
Maybe you are looking for
-
Do you know what may be causing this?
-
How to reformat Imac OS10.7
I just bought a new Imac, after did the migration from my old computer found out a lot of error, like fontbook not activated..... so just wanna reformat the Imac to Migrate again
-
Networking macbook with Desktop PC using airport??
Ok well at the moment I have an pc running on windows(with a dialup net connection) and im looking at buying a macbook and i was wondering if i buy a wireless PCI (desktop) adaptor here: http://www.dse.com.au/cgi-bin/dse.storefront/4471682d096f293a27
-
Scrollbar in layer window is not working properly.
There seems to be a bug with the scroller belonging to the tools. The functionality of a scrollbar is simple. You can pull it or you can click above or below the pull bar to make it move. The latter functionality is not working. See image for further
-
Getting Invalid Registry Object while uninstalling plugins programatically
When a specific condition is hit (while the user is trying to open our perspective), we uninstall the plugins using the below code: Platform.getBundle(<Bundle name>).uninstall(); When we run this code on Juno 4.2.2, we are hitting the below exception