‎2007 Dec 20 7:13 AM
Hello friends,
I am using FM 'gui_download' to download data into
excel sheet.
But the fields on the excel sheet gets compressed in length
while downloading.
So what should I do in order to get the data with proper field length.
Please reply my query as this is urgent.
Regards,
Sapna Agarwal
‎2007 Dec 20 7:17 AM
Hi
I excel sheet adjust the colum width,then you will get the required data
Regards
Shibin
‎2007 Dec 20 7:19 AM
Hi Shibin,
Actually I dont manually want to adjust the column in the downloaded file.
what i need to do is to get the adjusted columns at runtime.
regards,
Sapna Agarwal
‎2007 Dec 20 7:36 AM
hi,
use this fucntion module 'WS_EXCEL' to solve your issue......
reward points if useful...........
‎2010 Mar 23 3:56 AM
Hi All,
I would like to download the excel with proper field length. I don't like to do manually the column adjustment after downloading the excel sheet. Please answer my query.
Thanks,
Umashankar
‎2007 Dec 20 7:53 AM
Hi Sapna,
You can try the following FMs
Gui_download is one of them the others are :
1)in class CL_GUI_ALV_GRID there is a method called EXPORT_TO_SPREAD_SHEET
2) 'RH_START_EXCEL_WITH_DATA'
using gui_download
3) SAP_CONVERT_TO_XLS_FORMAT
Regards,
Lalit
‎2010 Mar 23 4:00 AM
Hi Sapna,
Have you solved your problem?. If yes can you please tell me the solution.
Thanks,
Umashankar
‎2010 Mar 23 4:10 AM
You can use FM 'SAP_CONVERT_TO_XLS_FORMAT' to download in excel format
‎2010 Mar 23 4:22 AM
Hi,
To download in excel use the following code. First you need to create one excel container at initialization event. Then download the same.
form sub_create_container .
Create Instance control for container
call method c_oi_container_control_creator=>get_container_control
importing
control = iref_control
error = iref_error.
if iref_error->has_failed = c_check.
call method iref_error->raise_message
exporting
type = 'E'.
endif.
Create generic container linked to container in screen 100
create object oref_container
exporting
container_name = 'CONT'
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 e000 with 'Error while creating container'(012).
endif.
Establish connection to GUI Control
call method iref_control->init_control
exporting
inplace_enabled = c_check
r3_application_name = 'EXCEL CONTAINER'
parent = oref_container
importing
error = iref_error
exceptions
javabeannotsupported = 1
others = 2.
if iref_error->has_failed = c_check.
call method iref_error->raise_message
exporting
type = 'E'.
endif.
Create Document Proxy
call method iref_control->get_document_proxy
exporting
document_type = soi_doctype_excel_sheet
importing
document_proxy = iref_document
error = iref_error.
if iref_error->has_failed = c_check.
call method iref_error->raise_message
exporting
type = 'E'.
endif.
endform.
Thanks
Subhankar.
Edited by: Subhankar Garani on Mar 23, 2010 5:22 AM
‎2010 Mar 23 4:24 AM
Use my previous post for container creation and for downloading use..
data: l_title type char40,
l_sheet type char12.
clear: v_row.
describe table <i_itab> lines v_row.
v_row = v_row + 1.
Populate the column heading
perform sub_pop_col_heading.
concatenate 'Assembly Table' v_char into l_title separated by space.
Create document
call method iref_document->create_document
exporting
open_inplace = c_check
document_title = l_title
no_flush = c_check
importing
error = iref_error.
Open Spreadsheet interface
call method iref_document->get_spreadsheet_interface
exporting
no_flush = c_check
importing
sheet_interface = iref_spreadsheet
error = iref_error.
Get number of sheets
call method iref_spreadsheet->get_sheets
exporting
no_flush = c_check
importing
sheets = i_sheets
error = iref_error.
read table i_sheets into wa_sheets index 1.
if sy-subrc = 0.
l_sheet = wa_sheets-sheet_name.
endif.
Select sheet
call method iref_spreadsheet->select_sheet
exporting
name = l_sheet
no_flush = c_check
importing
error = iref_error.
call method iref_spreadsheet->set_selection
exporting
top = 1
left = 1
rows = 1
columns = 1
no_flush = c_check
importing
error = iref_error.
call method iref_spreadsheet->insert_range
exporting
name = 'PRANGE'
rows = v_row
columns = v_col
no_flush = c_check
importing
error = iref_error.
Set the format of the cells
call method iref_spreadsheet->set_format
exporting
rangename = 'PRANGE'
typ = 0
currency = 'USD'
no_flush = 'X'
decimals = 2
importing
error = iref_error.
Get field names
call function 'DP_GET_FIELDS_FROM_TABLE'
tables
data = <i_itab>
fields = i_field_tab.
Insert records
call method iref_spreadsheet->insert_one_table
exporting
data_table = <i_itab>
fields_table = i_field_tab
rangename = 'PRANGE'
wholetable = c_check
no_flush = c_check
importing
error = iref_error.
Thanks
subhankar
‎2010 Mar 23 4:38 AM
Hi Dude,
Thanks for your reply. Will it apply to the excel sheet that will be sent in mail by report execution.
Say suppose if i execute the report and once it is done the output will be mailed to our user id given in the selection screen.
Once you open the excel sheet in your mail, the colum should be adjusted as per the text size.
Is it possible?
Thanks,
Umashankar
‎2010 Mar 23 4:41 AM
Hi,
You can try using FM:
XXL_FULL_API
ALSM_EXCEL_TO_INTERNAL_TABLE
and also FM:
GUI_DOWNLOAD wherein the filename parameter you can give its value as .XLS.
Hope it helps
Regards
Mansi
‎2010 Mar 23 10:35 AM
Or you can try to follow one of these blogs:
/people/otto.gold/blog/2010/02/09/happy-reporting-with-abap-ole-excel
/people/otto.gold/blog/2010/02/11/happy-reporting-with-excel-ii
Regards Otto
‎2010 Mar 23 11:53 AM
if use version 4.7 then use OPEN DATASET filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.