One Excel , Multiple Worksheets
Hello,
I have a requirement to read the excelsheet having multiple worksheets.
The excel will have sheet1, sheet2, sheet3 etc with data and I have to read all of them.
I searched a lot on SDN and fould the below code which is reading only the Active Sheet. Not all the sheets.
Any idea how this could be achieved?
I am pasting the code for your reference whici reads teh Active sheet.
=======================
*& Report ZSCD_TEST16
REPORT ZSCD_TEST16.
Define Screen Container
DATA: obj_container TYPE REF TO cl_gui_custom_container.
DATA: o_error TYPE REF TO i_oi_error,
o_control TYPE REF TO i_oi_container_control,
o_document TYPE REF TO i_oi_document_proxy,
o_spreadsheet TYPE REF TO i_oi_spreadsheet,
o_sheetname TYPE SOI_SHEETS_TABLE.
Data declarations.
DATA: t_files TYPE filetable,
s_files TYPE file_table,
v_doc_name TYPE char256,
v_changed TYPE int4,
v_rcode TYPE int4,
t_ranges TYPE soi_range_list,
s_ranges TYPE soi_range_item,
t_data TYPE soi_generic_table,
s_data TYPE soi_generic_item,
v_action TYPE int4.
Initialization event.
INITIALIZATION.
CLASS c_oi_errors DEFINITION LOAD.
Create Instance control for container
CALL METHOD c_oi_container_control_creator=>get_container_control
IMPORTING control = o_control
error = o_error.
IF o_error->has_failed = 'X'.
CALL METHOD o_error->raise_message
EXPORTING type = 'E'.
ENDIF.
Create generic container linked to container in screen 100
CREATE OBJECT obj_container
EXPORTING
container_name = 'CONTAINER'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc <> 0.
MESSAGE e208(00) WITH 'Error creating container'.
ENDIF.
Establish connection to GUI Control
CALL METHOD o_control->init_control
EXPORTING r3_application_name = 'Excel Document Container'
inplace_enabled = 'X'
parent = obj_container
IMPORTING error = o_error.
IF o_error->has_failed = 'X'.
CALL METHOD o_error->raise_message
EXPORTING type = 'E'.
ENDIF.
Create Document Proxy
CALL METHOD o_control->get_document_proxy
EXPORTING document_type = soi_doctype_excel_sheet
IMPORTING document_proxy = o_document
error = o_error.
IF o_error->has_failed = 'X'.
CALL METHOD o_error->raise_message
EXPORTING type = 'E'.
ENDIF.
Start-of-selection.
START-OF-SELECTION.
Call dialog to navigate to file
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_extension = '.xls'
file_filter = '*.xls'
initial_directory = 'C:\'
CHANGING
file_table = t_files
rc = v_rcode
user_action = v_action
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE e208(00) WITH 'FILE_OPEN_DIALOG'.
ENDIF.
Only continue if User hasn't cancelled
CHECK: v_action = 0.
Determine filename to open Excel document
READ TABLE t_files INDEX 1 INTO s_files.
IF sy-subrc = 0.
CONCATENATE 'FILE://' s_files-filename INTO v_doc_name.
ELSE.
MESSAGE e208(00).
ENDIF. "sy-subrc = 0
Open Spreadsheet in SAPWORKDIR
CALL METHOD o_document->open_document
EXPORTING open_inplace = 'X'
document_title = 'Excel'
document_url = v_doc_name
no_flush = ''
IMPORTING error = o_error.
IF o_error->has_failed = 'X'.
CALL METHOD o_error->raise_message
EXPORTING type = 'E'.
ENDIF.
Open Spreadsheet interface
CALL METHOD o_document->get_spreadsheet_interface
EXPORTING no_flush = 'X'
IMPORTING sheet_interface = o_spreadsheet
error = o_error.
IF o_error->has_failed = 'X'.
CALL METHOD o_error->raise_message
EXPORTING type = 'E'.
ENDIF.
Set selection for 1000 rows
CALL METHOD o_spreadsheet->set_selection
EXPORTING top = 1
left = 1
rows = '10'
columns = '10'
UPDATING = '-1'.
Define Range in spreadsheet
CALL METHOD o_spreadsheet->insert_range
EXPORTING name = 'Sheet2'
rows = '10'
columns = '20'
no_flush = ''
IMPORTING error = o_error.
IF o_error->has_failed = 'X'.
CALL METHOD o_error->raise_message
EXPORTING type = 'E'.
ENDIF.
Define Range in spreadsheet
CALL METHOD o_spreadsheet->GET_SHEETS
EXPORTING no_flush = ''
UPDATING = '-1'
IMPORTING SHEETS = o_sheetname.
s_ranges-name = 'Sheet2'.
s_ranges-rows = '10'.
s_ranges-columns = '20'.
APPEND s_ranges TO t_ranges.
Get data
CALL METHOD o_spreadsheet->get_ranges_data
EXPORTING all = '-1'
no_flush = ' '
IMPORTING contents = t_data
error = o_error
CHANGING ranges = t_ranges.
IF o_error->has_failed = 'X'.
CALL METHOD o_error->raise_message
EXPORTING type = 'E'.
ENDIF.
Close document
Close the document
CALL METHOD o_document->close_document
EXPORTING do_save = ''
no_flush = ''
IMPORTING has_changed = v_changed
error = o_error.
IF o_error->has_failed = 'X'.
CALL METHOD o_error->raise_message
EXPORTING type = 'E'.
ENDIF.
Clear Document Resources
CALL METHOD o_document->release_document
EXPORTING no_flush = ''
IMPORTING error = o_error.
IF o_error->has_failed = 'X'.
CALL METHOD o_error->raise_message
EXPORTING type = 'E'.
ENDIF.
Clear table of file names
FREE: t_files,
o_control.
Display the data
LOOP AT t_data INTO s_data.
AT NEW row.
SKIP.
ENDAT.
WRITE:(10) s_data-value.
ENDLOOP.
========================
Thanks in advance.
reagrds,
Try this Links
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-UploaddatafromExceltoSapusing+OO
How to read the data from different TABs(sheet1,sheet2..) in the Excel file
How to send data to different tabs of an excel sheet?
into excel sheet with multiple tabs
Similar Messages
-
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 -
C# Script to open and read an Excel spreadsheet with multiple worksheets
Can someone provide me the C# syntax and Edit Script to open an Excel spreadsheet with multiple worksheets and then using the data to create and output a .csv file? The multiple worksheets contain different data elements that I'll need to parse out and then
store as a .csv file that will then be read to pump data into our SQL Server Database.
Thanks for your review and am hopeful for a reply.
PSULionRPI think this code originally came from Joel, who comes here quite a bit. I'm not a C# expert, like Joe is, but I think this is pretty close to what you want.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Excel;
using System.IO;
namespace WindowsFormsApplication2
public partial class Form1 : Form
public Form1()
InitializeComponent();
private void button1_Click(object sender, EventArgs e)
Main();
public void Main()
string filePath = "C:\\Users\\Ryan\\Desktop\\MainExcel.xlsx";
Microsoft.Office.Interop.Excel.Application xlobj = new Microsoft.Office.Interop.Excel.Application();
Workbook w = default(Workbook);
Workbook w1 = default(Workbook);
Worksheet s = default(Worksheet);
Worksheet s1 = default(Worksheet);
Worksheet xlsht = default(Worksheet);
xlobj.Visible = true;
int intItem = 1;
DirectoryInfo dirSrc = new DirectoryInfo(@"C:\Users\Ryan\Desktop\Test_Folder\");
foreach (FileInfo ChildFile in dirSrc.GetFiles())
try
// Renaming the excel sheet
w = xlobj.Workbooks._Open(ChildFile.FullName,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
w1 = xlobj.Workbooks._Open(filePath,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
//this doesn't make any sense
//w1 = xlobj.Workbooks.Open(filePath);
//if (intItem > 3)
Excel.Worksheet lastSht =
(Excel.Worksheet)w1.Worksheets[w1.Worksheets.Count];
xlsht = (Excel.Worksheet)w1.Worksheets.Add(Type.Missing,
lastSht,
Type.Missing, Type.Missing);
s = (Excel.Worksheet)w.Worksheets[1];
s1 = (Excel.Worksheet)w1.Worksheets[intItem];
s1.Name = ChildFile.Name;
// it will copy and paste sheet from one to another with formula
s.UsedRange.Copy(Type.Missing);
Excel.Range r = s1.get_Range("A1", Type.Missing);
r.PasteSpecial(Excel.XlPasteType.xlPasteValues,
Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone,
Type.Missing, Type.Missing);
s1.UsedRange.Formula = s.UsedRange.Formula;
// Renaming the excel sheet
//w.Save();
w.Close(false, Type.Missing, Type.Missing);
w1.Close(false, Type.Missing, Type.Missing);
catch (Exception ex)
//w.Save();
w1.Save();
w.Close(false, Type.Missing, Type.Missing);
w1.Close(false, Type.Missing, Type.Missing);
intItem = intItem + 1;
//Dts.TaskResult = ScriptResults.Success
Do you need help getting everything into a CSV, or can you take it from here???
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
Exporting data from a multiple worksheet excel to oracle database.
Hi,
Am having a very big problem,i have to export data from excel to database.My excel is havin multiple worksheet.
I thought of most of the options nothing is suiting my layout.
SQL loader ,can't use due to multiple worksheet.
HSServices can;t use because my column headings are row wise,and the excel start with a big Heading rather than having column headings.
UTL_FILE can't use beacuse of multiple worksheet,and frankly speaking i don't know how to use utl file with excel to read paticular cell in excel.
ThanksFirst of all: this is a forum of volunteers.
So no one is obliged to respond to you.
Therefore 'urgent' does not exist in this forum, and labeling your request as 'urgent' is considered rude by many. If it is really that urgent, submit a prio 1 request at Metalink.
Secondly, I don't think you thought of most of the options.
Yes, you can use SQL*Loader as you can dump each individual worksheet to a separate CSV file.
Also, you didn't consider ODBC. If ODBC in Excel is too cumbersome, you can use MsAccess to hook the Excel sheet in Msaccess, connect to the database using the Oracle ODBC driver and design an ordinary append query,
Obviously, you would need one query per worksheet.
Hth
Sybrand Bakker
Senior Oracle DBA -
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 -
Extract program to extract data from SAP into multiple worksheets of excel
Hi , I am currently facing an issue.
Extracting the data during data extraction, conversion into an excel and also into multiple worksheets withing a excel file.
What is the function which can help me. Also how do you give refernce to multiple worksheets to be created withing a excel file (which is the destination)
Any sample program extracting data from SAP tables into a excel with multiple worksheet will be of immense help
Please respond. Appreciate it.
Rgds
MadhuHi Madhu,
Here is the program for creating the excel file and creating the multiple worksheets.
*& Report ZEXCEL_UPLOAD2
REPORT ZEXCEL_UPLOAD2.
INCLUDE ole2incl.
DATA: application TYPE ole2_object,
workbook 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, formula(50), END OF itab3.
*START-OF-SELECTION
START-OF-SELECTION.
APPEND: 'Peter' TO itab1, 'Ivanov' TO itab2,
'=Sheet1!A1 & " " & Sheet2!A1' TO itab3,
'John' TO itab1, 'Smith' TO itab2,
'=Sheet1!A2 & " " & Sheet2!A2' TO itab3.
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 0.
CALL METHOD OF application 'Workbooks' = workbook.
CALL METHOD OF workbook 'Add'.
Create first Excel Sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 1.
CALL METHOD OF sheet 'Activate'.
SET PROPERTY OF sheet 'Name' = 'Sheet1'.
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 'Value' = itab1-first_name.
ENDLOOP.
Create second Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 2.
SET PROPERTY OF sheet 'Name' = 'Sheet2'.
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 'Value' = itab2-last_name.
ENDLOOP.
Create third Excel sheet
CALL METHOD OF application 'Worksheets' = sheet
EXPORTING #1 = 3.
SET PROPERTY OF sheet 'Name' = 'Sheet3'.
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-formula.
SET PROPERTY OF cells 'Value' = itab3-formula.
ENDLOOP.
Save excel speadsheet to particular filename
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = 'c:\temp\exceldoc1.xls' "filename
#2 = 1. "fileFormat
Closes excel window, data is lost if not saved
SET PROPERTY OF application 'visible' = 0.
**Quick guide to some of the OLE statements for OLE processing in this program as well as a few other ones.
Save Excel speadsheet to particular filename
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = 'C:\Users\dprasad\Desktop\excel_sheet.xls' "filename
#2 = 1. "fileFormat
Save Excel document
CALL METHOD OF sheet 'SAVE'.
Quits out of Excel document
CALL METHOD OF sheet 'QUIT'.
Closes visible Excel window, data is lost if not saved
SET PROPERTY OF application 'visible' = 0. -
MULTIPLE WORKSHEETS PER EXCEL WORKBOOK USING XSLT
Hi everybody,
My query is on how multiple worksheets per excel file can be created using xslt programming.
From my report program i call the xslt transformation passing an internal table. Based on the changes in the values of a particular field in the table, multiple worksheets are to be created in a single excel file.
A snippet of the code ive generated is displayed below .But i get the error saying its unable to open the file. I need to know where exactly to place the <for-each select> and <worksheet> statements in order to successfully implement the solution. Would greatly appreciate any help offerred in this direction. Thanks
<xsl:template match="/">
<workbook>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
</ExcelWorkbook>
<xsl:apply-templates />
</Workbook>
</xsl:template>
<xsl:template match="asx:values">
<xsl:for-each select="ROWS/ZWORKSHEET">
<Worksheet ss:Name="FIRSTCOL">
<Table ss:ExpandedColumnCount="10" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="66" ss:DefaultRowHeight="14.25">
<Row xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Cell ss:StyleID="s23"><Data ss:Type="String">SAP Material Number</Data></Cell>
<Cell ss:StyleID="s23"><Data ss:Type="String">CLP</Data></Cell>
</Row>
</Table>
</Worksheet>
</xsl:for-each>
</xsl:template>
</xsl:transform>If the Sales Org values are static, you shold be able to create a variant. Don't know off what the variable name is off the top of my head, but there should be a variable delivered as part of business content that obtains the current month - look at the 0CALMONTH variables. (May be something like 0CMONTH ?)If you don't see it, maybe that variable activated yet.
Does just one person run this workbook or are many people?
If you schedule the query with reporting agent, you should be able to warmup (load the results)to the OLAP cache so when the user runs the querys later, they'll run very quickly, retrieving the data from the OLAP cache. BEx Broadcaster is a good option too if the criteria for the queries are all known upfront.
Message was edited by: Pizzaman
Fogo to ask - are you using hierarchies in the query? They can have a lot of perfromance impacts on the front end interms of rendering them in Excel. There are some Front End patches that speed this up quite a bit. -
Export data to excel with multiple worksheet
Hi all,
Thanks to Roel, Andy, Scott, and Varad. I could go this far with my first project with APEX :)
thank you guys !!
I am left with one last bit (unless the client request more feature). I need to export the database to an excel spreadsheet.
I have about 5 tables so I need to create 5 worksheet in the excel file.
Now I have tried OWA_SYLK from Tom (http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:728625409049#PAGETOP)
it works in my environment, but I just don't know how to create multiple worksheet in one excel file.
I read on the internet that XML spreadsheet is the answer but how to do that, I don't know.
Can anyone enlighten me?
Thanks.
JoelIt's easy with free RXLS PL/SQL library :
Procedure Test_002 is
wbk RXLS.XLS_WorkBook; -- workBook data structure
f1 integer; f2 integer; -– two workSheets
Begin
RXLS.NewWorkBook (wbk); -- new WorkBook init.
-- two worksheets creation
f1 := RXLS.NewSheet (Wbk,'Departments');
f2 := RXLS.NewSheet (Wbk,'Employees');
-- Writing into the first WorkSheet data from the first SQL request (DEPT)
RXLS.SQLtoXLS (xSQL => 'select * from Dept', xSheet => f1, xWbk => wbk, xR => 3, xC=> 2,
xMaxRows => 100, xMaxCols => 20);
-- Writing into the second WorkSheet data from the second SQL request (EMP)
RXLS.SQLtoXLS (xSQL => 'select * from Emp', xSheet => f2, xWbk => wbk, xR => 1, xC => 3,
xMaxRows => 20, xMaxCols => 10);
-- Excel Workbook or Open Office document , (MS XML 2003 format)
RXLS.GenXLS (wbk);
-- Dowload to IE or FF
RXLS.Show (wbk);
end; -- ex 2
[www.rci-informatique.fr/rxls] -
Excel Upload With Multiple Worksheets
Friends,
I have requirement wherein I have to read data from an excel file with multiple worksheets. I have gone through some earlier postings but most of them explain about creating an excel file with multiple worksheets (which is right oppsite of what I need to do)
I am trying to understand the concept of OLE and implement it but am finding it tricky!
Please help me out!
Thanks,
ShyamSee this site: AN EASY REFERENCE FOR OLE AUTOMATION by Serder Simsekler.
Best!
Jim -
Excel download with multiple worksheets using ABAP webdynpro
Content of Internal table should to downloaded to an excel sheet with multiple worksheet.
Excel doesn't support multiple worksheets with the text tab delimited or any of the other plain text formats. So if you need multiple worksheets those approaches are out. Multiple worksheets would only work with the Excel native format or the XML based format. From ABAP the best approach would be to create the XML Excel format. Search the forms and wiki has there has been tons of discussion in the mast on the XML Excel format.
-
Upload data from multiple worksheets of excel file into SAP by using MIME?
Hi all,
I'm trying to getting the data from a multiple worksheet excel file by usin the MIME Repository.
First of all i realizied it like [here|http://abap-explorer.blogspot.com/2008/12/upload-data-from-multiple-worksheets-of.html] in a normal ABAP Report.
By trying to transfer the code to a WebDynpro Component, i get problems.
With this part of code, because ActiveX is not allowed in our Webbrowser. So i have to find another solution to get the data from the excel file.
CALL METHOD c_oi_container_control_creator=>get_container_control
IMPORTING
control = iref_control
error = iref_error
I tried to rebuild this solution in webdynpro. But it dont works.
So my next step was trying to Read the Excel sheet directly from MIME by getting the Content (XString).
But there is no useful information Just a mix out of '######' and other symbols.
By converting it into String the same problem.
Maybe someone has an idea how to rebuild [this code|http://abap-explorer.blogspot.com/2008/12/upload-data-from-multiple-worksheets-of.html] in Webdynpro that it works correctly.
Currently Im Using the Fileupload UI Element. All Works fine. I can Upload the Excel file to MIME Repository and i can open it from there.
But i cant get the same clear informationen from the file, to write it later in a Database, like before without webdynpro.
i hope someone can help me.
Edited by: Sascha Baumann on Apr 20, 2009 4:28 PMYou can't read the native binary Excel Format in server side ABAP. The functions and classes that did this in Classic Dynpro used OLE Automation via the SAPGUI Control Framework to remotely control Excel to read the data. Because in the browser you have no connection to the SAPGUI or are sandboxed inside the browser; the same functionality is not possible.
I would suggest that you look into saving the Excel file as a open, text format. You might be able to use XML (although the Excel XML format can be complex) to support multiple sheets. You would have to build the logic yourself (using XSLT or the iXML parser) to process the XML format back into ABAP data. -
Can we combine multiple excel files into one excel file using SSIS?
I have a bunch of excel files in a specified folder. I wanted to combine all the excel files into one excel file by adding additional tabs in one excel file. Can I do this using SSIS?
OR
I know using macro we can combine multiple excel files. Can we run a excel macro in SSIS? Please help me.
Actually the complete package is this:
Step1: Using FTP task I'm downloading the bunch of excel files into a folder.
Step2: Above implementation is the second step that I have to do.You can do it in two steps
1. First get all data from excel sheets to a sql staging table. For that you need to use a looping logic as explained in below link (you dont required the additional logic used for checking file name etc in below example as you need all files). Also make
source as excel instead of flat file
http://visakhm.blogspot.in/2012/05/package-to-implement-daily-processing.html
2. Once you get the data onto a single table, use below to get it exported to multiple sheets within same excel destination file
http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Save multiple waveform graphs and data in one Excel File
Hi there,
I managed to save data from waveform graph into excel file and saving the plot into excel but individually. I'm aiming to save both the data and the plot in an excel file. May I know how do I do it? I've tried using the Write to Measurement File vi and also the invoke node of the waveform chart but it's still not giving me what I've wanted.
The above was only for one analog input channel and I have 2 analog inputs each with their respective sets of data and plot. Is there a way to execute the data and plot of one input in one worksheet and another set of data and plot in another worksheet, all in one excel file?Hi there;
I would recommend using the Report Generation Toolkit; it is the easiest way.
You can use either the Report Express VI or the Appi to save all your data in both formats
Greetings -
Export XML data into multiple worksheet of an Excel file..using FO processr
Hi,
I need to export XML data into Excel output, the data should flow into multiple worksheet of the Excel file.
Let me know if this can be done using XML publisher. If yes, please provide me the steps to do the same.
Could not able to achieve this through by the below process:
(1) Created a RTF (which has single excel table structure).
(2) Generated the XSL file using XSL-FO Style Sheet.
(3) Passed the XSL file and XML
which exported the data into an Excel (single worksheet) format.
Please let me know, how this can be exported into multiple worksheets.
Thanks & Regards,
Dhamodaran VJ.Hi Dhamodaran ,
pass me the template you created and XML. "Created a RTF (which has single excel table structure)."
Let me have a look at it,
For ID, look at profile. -
Publish XML payload in multiple worksheet in Excel: How can we do?
I am using BI publisher standalone version.
How can I parse a payload which has a million row to multiple worksheets of 30,000 records for example?Check out these links:
http://livedocs.adobe.com/flex/3/html/help.html?content=CopyAndPaste_6.html
http://livedocs.adobe.com/flex/3/html/help.html?content=Working_with_Bitmaps_03.html
If this post answers your question or helps, please mark it as such.
Maybe you are looking for
-
Split Apart Scanned Photos Automatically
There is a similar issue here: Break apart photos automatically, but I figured I might get better luck posting a new post than replying on one that is over 8 years old. Anyways, I have an Epson Perfection 600 Flat Bed Scanner. The Epson scanner softw
-
Deploying a javadb desktop app (Creating by netbeans 6)
Hello, How can I create a javadb embedded database inside the project's folder? By default the javadb created in netbeans it locates itself on .netbeans folder in documents and settings. The purpose of this is to have the database inside the project
-
GUI in Java for a C program.
Hi, I have a console program written in C. Can I make the GUI for this program in Java ? The user passes on arguments to the C program through the command line using switches. So instead, the java application will now have input boxes etc to take in
-
Safari - Slow Script Error (10.5.1)
I've been getting a slow script error while surfing a website's forum, this is what it says, "A script on the page "IGN Boards - Choose A Board" (http://boards.ign.com/) is making Safari unresponsive. Do you want to continue running the script, or st
-
HT1349 display well not go on landscape mode
well not go on to landscape mode