2006 Aug 21 5:11 AM
Hi,
My requirement is to check that the cells of the uploaded excel file are in "Text" format. Is there any function module that I can use?
Thanks.
2006 Aug 21 6:52 AM
Hi,
you can use OLE in that case.
Ex: 1
REPORT ZTEST_EXCEL .
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),
last_name(10),
END OF itab1.
START-OF-SELECTION.
itab1-first_name = '123445'.
itab1-last_name = 'tesst'.
append itab1.
clear itab1.
itab1-first_name = '123446'.
itab1-last_name = 'tesst'.
append itab1.
clear itab1.
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 1.
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.
index = index + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Value' = itab1-last_name.
ENDLOOP.
Save excel speadsheet to particular filename
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = 'c:\temp\exceldoc1.xls' "filename
#2 = 1. "fileFormat
ex 2:
report zole_example.
include ole2incl.
data: e_sheet type ole2_object.
data: e_appl type ole2_object.
data: e_work type ole2_object.
data: e_cell type ole2_object.
data: field_value(30) type c.
parameters: p_file type localfile default 'C:\RichTest.xls'.
start-of-selection.
Start the application
create object e_appl 'EXCEL.APPLICATION'.
set property of e_appl 'VISIBLE' = 1.
Open the file
call method of e_appl 'WORKBOOKS' = e_work.
call method of e_work 'OPEN'
exporting
#1 = p_file.
Write data to the excel file
do 20 times.
Create the value
field_value = sy-index.
shift field_value left deleting leading space.
concatenate 'Cell' field_value
into field_value separated by space.
Position to specific cell in Column 1
call method of e_appl 'Cells' = e_cell
exporting
#1 = sy-index
#2 = 1.
Set the value
set property of e_cell 'Value' = field_value .
Position to specific cell in Column 2
call method of e_appl 'Cells' = e_cell
exporting
#1 = sy-index
#2 = 2.
Set the value
set property of e_cell 'Value' = field_value .
enddo.
Close the file
call method of e_work 'close'.
Quit the file
call method of e_appl 'QUIT'.
free object e_appl.
Reward points if helpful.
Regards,
Harini.S
Hi Gurus,
I developed the program by using same functionaliy
iam getting below error iam unable to find why the error is comming
please advice me
Errro : To many selection conditions with length > 30 in WHERE_CLAUSES
Message no. DB895
Regards
RameshG
Edited by: RameshG on Apr 15, 2011 7:32 PM
2006 Aug 21 6:52 AM
Hi,
you can use OLE in that case.
Ex: 1
REPORT ZTEST_EXCEL .
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),
last_name(10),
END OF itab1.
START-OF-SELECTION.
itab1-first_name = '123445'.
itab1-last_name = 'tesst'.
append itab1.
clear itab1.
itab1-first_name = '123446'.
itab1-last_name = 'tesst'.
append itab1.
clear itab1.
CREATE OBJECT application 'excel.application'.
SET PROPERTY OF application 'visible' = 1.
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.
index = index + 1. " 1 - column name
CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
SET PROPERTY OF cells 'Value' = itab1-last_name.
ENDLOOP.
Save excel speadsheet to particular filename
CALL METHOD OF sheet 'SaveAs'
EXPORTING #1 = 'c:\temp\exceldoc1.xls' "filename
#2 = 1. "fileFormat
ex 2:
report zole_example.
include ole2incl.
data: e_sheet type ole2_object.
data: e_appl type ole2_object.
data: e_work type ole2_object.
data: e_cell type ole2_object.
data: field_value(30) type c.
parameters: p_file type localfile default 'C:\RichTest.xls'.
start-of-selection.
Start the application
create object e_appl 'EXCEL.APPLICATION'.
set property of e_appl 'VISIBLE' = 1.
Open the file
call method of e_appl 'WORKBOOKS' = e_work.
call method of e_work 'OPEN'
exporting
#1 = p_file.
Write data to the excel file
do 20 times.
Create the value
field_value = sy-index.
shift field_value left deleting leading space.
concatenate 'Cell' field_value
into field_value separated by space.
Position to specific cell in Column 1
call method of e_appl 'Cells' = e_cell
exporting
#1 = sy-index
#2 = 1.
Set the value
set property of e_cell 'Value' = field_value .
Position to specific cell in Column 2
call method of e_appl 'Cells' = e_cell
exporting
#1 = sy-index
#2 = 2.
Set the value
set property of e_cell 'Value' = field_value .
enddo.
Close the file
call method of e_work 'close'.
Quit the file
call method of e_appl 'QUIT'.
free object e_appl.
Reward points if helpful.
Regards,
Harini.S
2006 Sep 14 12:24 AM
Hi,
how can i lock the entire rows based on certain condition.my req is some rows should get locked in excel
Thanks in advance
Leoiz
2011 Apr 15 3:01 PM
Hi Gurus,
I developed the program by using same functionaliy
iam getting below error iam unable to find why the error is comming
please advice me
Errro : To many selection conditions with length > 30 in WHERE_CLAUSES
Message no. DB895
Regards
RameshG
Edited by: RameshG on Apr 15, 2011 7:32 PM
2006 Aug 21 7:56 AM
hi
good
i dont think there is any function module who ll help you for this kind of requirement. You have not mentioned when and how you r checking the particular excel file,
if you using GUI_UPLOAD i dont think there would be any prob, it will automatically convert from binary to text and you ll get in the text format only, if you r using any other function module, than there might be some prob.
thanks
mrutyun
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |