ColdFusion Search with Excel Sheet creation
I created a form search with two buttons - one for results on the web page and one to create an excel sheet.
Problem: When a user conducts a search with results on the web page - the user would have to select the criteria again then click the create excel button to create the sheet.
How can I work it, so the user after conducting a search can just click one button to create the excel sheet?
(Using "Post" for the form - will change to get if needed will your help)
I'm still freshman with CF - this means I have a lot of questions.
When I tried using the excel.cfm page I receive: Variable MRESULTS is undefined.
How do I send "mresults" to the excel page?
Search Page Link:
<a href="javascript:document.
getElementById('yourForm').submit()">Excel</a>
<form id="yourForm" action="excel.cfm" method="post">
<!--- save search values sent via POST --->
<cfoutput>
<input name="ship" value="#mresults.ship#">
</cfoutput>
</form>
Excel page:
<cfquery name="MResults"
datasource="support">
select *
from table1
<cfform action="/msr/excel.cfm" method="post">
<cfset sObj=SpreadsheetNew()>
<!--- Create header row --->
<cfset SpreadsheetAddRow(sObj, "Name,address")>
<cfset SpreadsheetFormatRow(sObj, {bold=TRUE,fgcolor="grey_25_percent", alignment="center"}, 1)>
<cfset SpreadsheetFormatColumn(sObj, {alignment="left", dataformat="mm/dd/yyyy"}, 14)>
<cfset SpreadsheetAddRows(sObj, MResults)>
<cfspreadsheet action="write" name="sObj" filename="C:Orders.xls" overwrite="true">
<cfheader name="Content-Disposition"
value="inline; filename=Orders.xls">
<cfcontent type="application/csv"
file="C:\Orders.xls"
deletefile="yes">
</cfform>
</cfquery>
Similar Messages
-
Urgent: Sending an Email with Excel sheet attachment
Hi All,
I am preparing a report and has to send mail with excel sheet attachement. In report i am getting everything fine. But in the mail i am not getting the data, data is passing to the FM succesfully. But in the mail, excel is not having full data.
the below mentioned is my code.
i_texts-line = c_stern.
i_texts-line+254(1) = c_newline.
APPEND i_texts.
LOOP AT i_texc.
i_att_line-line = i_texc.
APPEND i_att_line.
ENDLOOP.
DATA: wa_doc_chng LIKE sodocchgi1.
DATA: w_tab_lines LIKE sy-tabix.
STATICS: c_body_start TYPE i VALUE '1'.
CONSTANTS: lc_filename(10) TYPE c VALUE 'Attachment',
lc_atthead(30) TYPE c VALUE 'Manually released invoices'.
DATA: i_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: w_doc_name(30) TYPE c.
DATA: l_text1(15),
l_text2(12),
l_text3(15),
l_text4(15),
l_text5(14),
l_text6(17),
l_text7(10),
l_text8(20),
l_text9(19),
l_text10(19),
l_text11(19),
l_text12(16),
l_text13(20),
l_text14(19),
l_text15(19),
l_text16(30).
DATA: DATE(10),
DT(2),
MON(3),
YR(4),
lc_final(50).
CLEAR: i_texts, i_reci,i_att_line. "i_bname,
REFRESH: i_texts, i_reci,i_att_line. "i_bname,
WRITE sy-datum TO w_datex.
WRITE sy-uzeit TO w_timex.
l_text1 = text-003.
l_text2 = text-004.
l_text3 = text-005.
l_text4 = text-006.
l_text5 = text-007.
l_text6 = text-008.
l_text7 = text-009.
l_text8 = text-010.
l_text9 = text-011.
l_text10 = text-012.
l_text11 = text-013.
l_text12 = text-014.
l_text13 = text-015.
l_text14 = text-016.
l_text15 = text-017.
l_text16 = text-026.
CONCATENATE
l_text1
l_text2
l_text3
l_text4
l_text5
l_text6
l_text7
l_text8
l_text9
l_text10
l_text11
l_text12
l_text13
l_text14
l_text15
l_text16
INTO i_texts SEPARATED BY
c_horz_tab.
i_texts-line+254(1) = c_newline.
APPEND i_texts.
CLEAR i_texts.
LOOP AT i_texc.
i_att_line-line = i_texc.
APPEND i_att_line.
ENDLOOP.
LOOP AT so_rec.
i_reci-receiver = so_rec-low.
i_reci-express = 'X'.
i_reci-rec_type = 'U'.
APPEND i_reci.
ENDLOOP.
DESCRIBE TABLE i_texts LINES w_tab_lines.
READ TABLE i_texts INDEX w_tab_lines.
wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
wa_obj_name = 'ZFI_XX_REL_BLOCKED_INVOICE_01'.
DT = SY-DATUM+6(2).
MON = SY-DATUM+4(2).
YR = SY-DATUM+0(4).
CONCATENATE DT MON YR INTO DATE SEPARATED BY '-'.
CONCATENATE lc_atthead date into lc_final separated by ' '.
MOVE lc_final
TO wa_obj_descr .
wa_doc_chng-obj_name = wa_obj_name.
wa_doc_chng-obj_descr = wa_obj_descr.
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 0.
i_objpack-body_num = w_tab_lines.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
APPEND LINES OF i_att_line TO i_texts.
LOOP AT i_arseg INTO wa_arseg.
i_xmplt_d-belnr = wa_arseg-belnr.
i_xmplt_d-budat = wa_arseg-budat.
i_xmplt_d-bukrs = wa_arseg-bukrs.
i_xmplt_d-lifnr = wa_arseg-lifnr.
i_xmplt_d-name1_lifnr = wa_arseg-name1_lifnr.
i_xmplt_d-wrbtr = wa_arseg-wrbtr.
i_xmplt_d-waers = wa_arseg-waers.
i_xmplt_d-ebeln = wa_arseg-ebeln.
i_xmplt_d-ebelp = wa_arseg-ebelp.
i_xmplt_d-reason = wa_arseg-reason.
i_xmplt_d-dmeng = wa_arseg-dmeng.
i_xmplt_d-dwert = wa_arseg-dwert.
i_xmplt_d-bname = wa_arseg-bname.
i_xmplt_d-name_text = wa_arseg-name_text.
i_xmplt_d-udate = wa_arseg-udate.
i_xmplt_d-comment = wa_arseg-comment.
APPEND i_xmplt_d.
ENDLOOP.
LOOP AT i_xmplt_d.
CONCATENATE i_xmplt_d-belnr
i_xmplt_d-budat
i_xmplt_d-bukrs
i_xmplt_d-lifnr
i_xmplt_d-name1_lifnr
i_xmplt_d-wrbtr
i_xmplt_d-waers
i_xmplt_d-ebeln
i_xmplt_d-ebelp
i_xmplt_d-reason
i_xmplt_d-dmeng
i_xmplt_d-dwert
i_xmplt_d-bname
i_xmplt_d-name_text
i_xmplt_d-udate
i_xmplt_d-comment
INTO i_texts SEPARATED
BY c_horz_tab.
i_texts-line+254(1) = c_newline.
APPEND i_texts.
CLEAR i_texts.
ENDLOOP.
DESCRIBE TABLE i_texts LINES w_tab_lines.
READ TABLE i_texts INDEX w_tab_lines.
wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
DESCRIBE TABLE i_texts LINES w_tab_lines.
i_objpack-transf_bin = ' '.
i_objpack-head_start = 0.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = w_tab_lines.
i_objpack-doc_type = 'XLS'.
i_objpack-obj_name = 'Attachment'.
i_objpack-obj_descr = w_doc_name.
i_objpack-obj_descr = lc_filename.
i_objpack-doc_size = w_tab_lines * 255.
APPEND i_objpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
TABLES
packing_list = i_objpack
contents_txt = i_texts
receivers = i_reci
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
WRITE: / 'Error in send E-Mail' .
ENDIF.
please revert me asap. It is very urgent to me. thanks in advance.
ByehI
Have you build your Excel Data table to get attachement in Mail? If no then please find the Eg. code for your reference to send Excel attachment..
* End of Selection Event : Displaying the selected data *
END-OF-SELECTION.
PERFORM EMAIL_EXCEL_ATTACHMENT.
******///form
FORM EMAIL_EXCEL_ATTACHMENT .
* Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
* Populate message body text
PERFORM POPULATE_EMAIL_MESSAGE_BODY.
* Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING S_EMAIL
TEXT-042
C_XLS
'filename'
CHANGING GD_ERROR
GD_RECIEVER.
* Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
ENDFORM. " EMAIL_EXCEL_ATTACHMENT
********///form BUILD_XLS_DATA_TABLE
FORM BUILD_XLS_DATA_TABLE .
DATA : LV_NETWR(20) TYPE C,
LV_BOL_DATE(20) TYPE C,
LV_KAWRT(20) TYPE C,
LV_FKDAT(20) TYPE C,
LV_WAERK(20) TYPE C,
LV_KURRF(20) TYPE C,
LV_SHIPDATE(20) TYPE C,
LV_DEPTDATE(20) TYPE C.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF. "#EC *
DATA STR TYPE STRING.
**********/ this parameter concatenate to get headers
CONCATENATE STR
'SLNO'
'OWNER'
'SERIAL NO'
'FROM'
'DESTINATION'
'INVOICE VALUE'
'DESCRIPTION'
'CUSTOMER NAME'
'BL NUMBER'
'BL DATE'
'VESSEL NAME/AIRLINE DETAILS'
'MODE OF TRANSIT'
'SHIPPING MARKS'
'DUTY SUM INSURED'
'FLAG'
'OPEN COVERNO'
'INVOICE DATE'
'INVOICE NO'
'LC WORDING'
'QUANTITY'
'PACKAGING DETAILS'
'BASIS OF VALUATION'
'EXCLUDE WAR SRCC'
'CURRENCY'
'EXCHANGE RATE'
'ADDRESS'
'VESSEL BUILT YEAR'
'VESSEL FLAG'
'VOYAGE NO'
'SHIPMENT DATE'
'DEPARTURE DATE'
'SURVEYOR COUNTRY'
'SURVEYOR CITY'
'SURVEYOR AGENT'
'SURVEYOR ADDRESS'
'EXPORT CONSIGNMENT'
'CONTAINER DETAILS'
CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
LOOP AT IT_FINAL.
*******/ this is to pass body / row data
WRITE : IT_FINAL-NETWR TO LV_NETWR, "#EC UOM_IN_MES
IT_FINAL-BOL_DATE TO LV_BOL_DATE,
IT_FINAL-KAWRT TO LV_KAWRT, "#EC UOM_IN_MES
IT_FINAL-FKDAT TO LV_FKDAT,
IT_FINAL-WAERK TO LV_WAERK,
IT_FINAL-KURRF TO LV_KURRF,
IT_FINAL-SHIPDATE TO LV_SHIPDATE,
IT_FINAL-DEPTDATE TO LV_DEPTDATE.
CONCATENATE
STR
IT_FINAL-SLNO
IT_FINAL-OWNER
IT_FINAL-SRNO
IT_FINAL-PORT_LOAD
IT_FINAL-PORT_DSCHR
LV_NETWR
IT_FINAL-DESCRIP
IT_FINAL-CUSTNAME
IT_FINAL-BOL_NUM
LV_BOL_DATE
IT_FINAL-VESSELNAME
IT_FINAL-SHP_TYPE
IT_FINAL-SHP_MARK
LV_KAWRT
IT_FINAL-FLAG
IT_FINAL-OPEN_CONO
LV_FKDAT
IT_FINAL-VBELN
IT_FINAL-LC_WORD
IT_FINAL-QUANT
IT_FINAL-PACKDETL
IT_FINAL-INCO1
IT_FINAL-EXCWSR
LV_WAERK
LV_KURRF
IT_FINAL-ADDPAY
IT_FINAL-VESSBYR
IT_FINAL-VESSFLG
IT_FINAL-VOY_FLY_NO
LV_SHIPDATE
LV_DEPTDATE
IT_FINAL-SURCOUNT
IT_FINAL-INCO2
IT_FINAL-EXPORT_CON
IT_FINAL-SURAGT
IT_FINAL-SURADD
IT_FINAL-CONTRNO
CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
ENDLOOP.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = STR
TABLES
FTEXT_TAB = IT_ATTACH.
ENDFORM. " BUILD_XLS_DATA_TABLE
******// form POPULATE_EMAIL_MESSAGE_BODY
FORM POPULATE_EMAIL_MESSAGE_BODY .
REFRESH IT_MESSAGE.
IT_MESSAGE = TEXT-043. " Please find attached Insurance Certificate details
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
*******'/ form SEND_FILE_AS_EMAIL_ATTACHMENT
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* text
* -->PIT_MESSAGE text
* -->PIT_ATTACH text
* -->P_EMAIL text
* -->P_MTITLE text
* -->P_FORMAT text
* -->P_FILENAME text
* -->P_ATTDESCRIPTION text
* -->P_SENDER_ADDRESS text
* -->P_SENDER_ADDRES_TYPE text
* -->P_ERROR text
* -->P_RECIEVER text
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER. "#EC *
DATA: LD_ERROR TYPE SY-SUBRC, "#EC *
* LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
* LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC. "#EC *
* ld_email = p_email.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
* Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
* Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
* Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
DESCRIBE TABLE IT_ATTACH LINES W_CNT.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
W_CNT * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
* Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'raw'.
APPEND T_PACKING_LIST.
* Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
* Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
LOOP AT S_EMAIL.
T_RECEIVERS-RECEIVER = S_EMAIL-LOW.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
* Populate zerror return code
LD_ERROR = SY-SUBRC.
* Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM. " SEND_FILE_AS_EMAIL_ATTACHMENT
*******/form
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
* text
* --> p1 text
* <-- p2 text
FORM INITIATE_MAIL_EXECUTE_PROGRAM .
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*********end of code to trigger mail in excel format....
If any other help please let me know......
I am sure this example code will help you to resolve your problem...
please analyse above code for your requirement...
In my scenario the message you said is not displaying.....
Reward Points -
Link labview data with excel sheets
I would like to save the output of a cluster(containing strings and numeric data) in a specific format(each data in respective columns)
in an excel sheet.
how do I do it in labview??
I tried mathscript, is there any other way? If there isnt can u suggest how can I use it to solve the above mentioned issue.
similarly, can I recieve data in real time from excel sheets??
pls suggest.
Solved!
Go to Solution.I think you should use the ActiveX to fullfill your requirements.
You can refer to this example
<LabVIEW Folder>\examples\comm\ExcelExamples.llb\Excel Macro Example.vi
Use activeX to write and read data.
Best Regards
Hu Yu -
Need to send email with excel sheet as attachment: URGENT
Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
For kind information...there is only one selection field for entering the mail id.
Thanks in advance
NandaHi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
For kind information...there is only one selection field for entering the mail id.
Thanks in advance
Nanda -
Hi: working with excel sheet
HI,
Please i need the code to activate the excel worksheet
cells after dowloading it to the desktop. I will appreciate your help.
rgs
p.kpHi,
<b>Demo Program</b>
RSOLETT1
RSDEMO01
XXLTTEST
XXLSTEST
XXLFTEST
Check this source Code ; Hope it helps
REPORT y_man_excel .
* this report demonstrates how to send some ABAP data to an
* EXCEL sheet using OLE automation.
INCLUDE ole2incl.
* handles for OLE objects
DATA: o_excel TYPE ole2_object, " Excel object
o_workbooks TYPE ole2_object, " list of workbooks
o_worksheet TYPE ole2_object, " workbook
h_zl TYPE ole2_object, " cell
h_f TYPE ole2_object. " font
TYPES: BEGIN OF ty_header,
create_date TYPE char20 ,
nomship_ref TYPE char20 ,
offer TYPE char20 ,
conf_ref_no TYPE char20 ,
con_eff_date TYPE char20 ,
status_date TYPE char20 ,
rej_text TYPE char20 ,
trf_date TYPE char20 ,
mprn TYPE char20 ,
mprn_status TYPE char20 ,
mam_app TYPE char20 ,
open_read TYPE char22 ,
END OF ty_header.
CONSTANTS :
lc_file_type TYPE char10 VALUE 'DAT'.
DATA : lit_ty_header TYPE TABLE OF ty_header,
wa_ty_header LIKE LINE OF lit_ty_header,
lv_file_name TYPE string.
CLEAR: lit_ty_header[],
wa_ty_header,
lv_file_name.
* Table of Coulumn Names.
wa_ty_header-create_date = 'Column one' .
wa_ty_header-nomship_ref = 'Column Two' .
wa_ty_header-offer = 'Column there' .
wa_ty_header-conf_ref_no = 'Column Four' .
wa_ty_header-con_eff_date = 'Column five' .
wa_ty_header-status_date = 'Column Six' .
wa_ty_header-rej_text = 'Column Seven' .
wa_ty_header-trf_date = 'Column Eight' .
wa_ty_header-mprn = 'Column Nine' .
wa_ty_header-mprn_status = 'Column Ten' .
wa_ty_header-mam_app = 'Column Eleven' .
wa_ty_header-open_read = 'Column 12' .
APPEND wa_ty_header TO lit_ty_header.
* File Name
CONCATENATE text-033
sy-uname
sy-datum
sy-uzeit
text-034
INTO lv_file_name.
CONDENSE lv_file_name.
*& Event START-OF-SELECTION
START-OF-SELECTION.
*----start Excel
CREATE OBJECT o_excel 'EXCEL.APPLICATION'.
*----Set non visible
SET PROPERTY OF o_excel 'Visible' = 1.
*----get list of workbooks, initially empty
CALL METHOD OF o_excel 'Workbooks' = o_workbooks.
PERFORM err_hdl.
*----add a new workbook
CALL METHOD OF o_workbooks 'Add' = o_worksheet.
* CALL METHOD OF o_worksheet 'Activate'.
* SET PROPERTY OF o_worksheet 'Name' = 'Page 1'.
PERFORM err_hdl.
* output column headings to active Excel sheet
PERFORM fill_cell USING 1 1 1 'Flug'(001).
PERFORM fill_cell USING 1 2 0 'Nr'(002).
PERFORM fill_cell USING 1 3 1 'Von'(003).
PERFORM fill_cell USING 1 4 1 'Nach'(004).
PERFORM fill_cell USING 1 5 1 'Zeit'(005).
CALL METHOD OF o_worksheet 'SAVEAS'
EXPORTING
#1 = 'c:kis_excel.xls'.
FREE OBJECT o_excel.
PERFORM err_hdl.
* 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 o_excel 'Cells' = h_zl
EXPORTING
#1 = i
#2 = j.
PERFORM err_hdl.
SET PROPERTY OF h_zl 'Value' = val .
PERFORM err_hdl.
GET PROPERTY OF h_zl 'Font' = h_f.
PERFORM err_hdl.
SET PROPERTY OF h_f 'Bold' = bold .
PERFORM err_hdl.
ENDFORM. "FILL_CELL
*& Form ERR_HDL
* outputs OLE error if any *
* --> p1 text
* <-- p2 text
FORM err_hdl.
IF sy-subrc <> 0.
WRITE: / 'error:-', sy-subrc.
STOP.
ENDIF. -
E61: Compatibility issue with Excel sheets
Hello,
I am having difficulties transferring an Excel file from my E61 to my laptop running Office 2007: I had originally written
the file in Office 2003 and I have now added two more sheets to the file and renamed the original sheet on my E61. When I tried transferring the file via the
data cable, I got a message saying unreadable contents were found in the file and asking me if I trusted the source. When I clicked OK, the file
was repaired, then I got a second message saying there might possibly be some data loss. Indeed, all the data was gone from
the Workbook. All the sheets I had added were there along with the one sheet that was there originally, but they were all blank. The **bleep** thing about this is that I had already transferred the file back and forth a few times without error.
I then tried with another Excel file that I had originally written on a PC running Office 2007 and it was nearly the same. In that file, all the data seemed
to be there, but the formatting was gone. In yet another file that I had written on the mobile, it was even worse - the numeric values that I had entered in
some cells seemed to be there, but incorrectly formatted while text cells were altogether gone.
Can anybody tell me what I did wrong there?
Thanks a lot!
Regards,
Hendikoischnur
P.S.: The same thing happened when I didn´t transfer the file to the laptop at all, but left the phone connected via cable
and tried to open the file from the memory card in Data transfer mode. Opening the file on the mobile itself, however, was no problem.
P.P.S.: This is really rather important - one of the files in question is a collection of all my personal passwords. Out of security
considerations, I´m thinking of having that file only on my mobile, copy it to the PC at need
and shred that copy afterwards, so it would be quite fatal if
I wasn´t able to transfer the file back to my Desktop or even open it in Data transfer mode.
IT will paint our future - either green or black
* ecosia, the eco-friendly search engine (powered by Yahoo/Bing/WWF);
* Searching for pics online? Try ecocho.eu or treehoo.com
* For those who don´t want to miss Google: Try znout.de - it´s Google running on green energy
* CO2-free chatting: Try Jabber-server.de (running on 100% waterpower)Hi,
does nobody have an idea about this? I have already contacted the Nokia Support, but the guy there asked me a lot of questions apt for complete computer-newbies without bringing me any nearer to a solution. I already thought that maybe my memory card is damaged - but then, the phone shouldn´t display the contents flawlessly.
Next I will try if maybe the problem is only with Office 2007 and I can open the files with Office XP or maybe with CALC, although that would be somewhat weird...
Regards,
Hendikoischnur
IT will paint our future - either green or black
* ecosia, the eco-friendly search engine (powered by Yahoo/Bing/WWF);
* Searching for pics online? Try ecocho.eu or treehoo.com
* For those who don´t want to miss Google: Try znout.de - it´s Google running on green energy
* CO2-free chatting: Try Jabber-server.de (running on 100% waterpower) -
Desktop Integration with Excel sheet
Hello Everyone,
I have a requirement where in i need to create an excel document with different format and data for each cell.Here i want to use office integration control .Can anyone provide me sample code to create a spreadsheet and passing the data to it through office integration..?.
I am also looking for other option where in instead of building document from scratch,i want to use one standard template which i should be able to open and pass the data to a certain cells of this document .Is it possible to implement this functionality through desktop integration controls..? Please do the needful.
Thank you in advance.
Regards,
Venkat.Hi,
By using OLE your code becomes very lengthy and you have to write your own
reusable subroutines. It is not suitable for complex requirement.
You can go for Desktop Office Integration (DOI) classes and their methods which serves
most of the common user requirements.
Please refer below examples
1. SAPRDEMO_SPREADSHEET_INTERFACE
2. SAPRDEMO_FORM_INTERFACE
Regards,
Vishal -
To send an email with attachment excel sheet
Hi Friends,
I am struk up at to send an eamil with Excel sheet.
I used FM SO_DOCUMENT_SEND_API1.
but is is sending an email but with out data
how to work this senario kindly help me please.
Thanks and Regards,
Bhavani.Hi,
https://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=61243822
Thanks,
Krishna... -
Issue in sending e mails with Excel attachment
Hi,
I am facing an issue with one function module - SO_DOCUMENT_SEND_API1. We were using this for sending mails to diff destination with excel sheet attachment contains sales data. This system has been migrated from 4.5B to ECC 5. Now this process is not working like the old one and the excel attachment is not properly formatted. All the data is being written into one cell of excel sheet and it seems only one line is present in output and is corrupted.
Can you please let me know what might be the issue here, any alternate option available or something to be modified in new version with this function module?
Thanks in advance,
UllasHi Ullas,
check this once.
REPORT ZLAXMI_ALVMAIL4 .
TABLES: EKKO.
PARAMETERS: P_EMAIL TYPE SOMLRECI1-RECEIVER
DEFAULT '[email protected]'.
TYPES: BEGIN OF T_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
AEDAT TYPE EKPO-AEDAT,
MATNR TYPE EKPO-MATNR,
END OF T_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF T_EKPO INITIAL SIZE 0,
WA_EKPO TYPE T_EKPO.
TYPES: BEGIN OF T_CHAREKPO,
EBELN(10) TYPE C,
EBELP(5) TYPE C,
AEDAT(8) TYPE C,
MATNR(18) TYPE C,
END OF T_CHAREKPO.
DATA: WA_CHAREKPO TYPE T_CHAREKPO.
DATA: IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
W_CNT TYPE I,
W_SENT_ALL(1) TYPE C,
W_DOC_DATA LIKE SODOCCHGI1,
GD_ERROR TYPE SY-SUBRC,
GD_RECIEVER TYPE SY-SUBRC.
*START_OF_SELECTION
START-OF-SELECTION.
Retrieve sample data from table ekpo
PERFORM DATA_RETRIEVAL.
Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
PERFORM POPULATE_EMAIL_MESSAGE_BODY.
Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING P_EMAIL
'Example .xls documnet attachment'
'XLS'
'filename'
CHANGING GD_ERROR
GD_RECIEVER.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP AEDAT MATNR
UP TO 10 ROWS
FROM EKPO
INTO TABLE IT_EKPO.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM BUILD_XLS_DATA_TABLE.
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
LOOP AT IT_EKPO INTO WA_CHAREKPO.
CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP
WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER.
DATA: LD_ERROR TYPE SY-SUBRC,
LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC.
LD_EMAIL = P_EMAIL.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND T_PACKING_LIST.
Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
T_RECEIVERS-RECEIVER = LD_EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
Populate zerror return code
LD_ERROR = SY-SUBRC.
Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM INITIATE_MAIL_EXECUTE_PROGRAM.
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
FORM POPULATE_EMAIL_MESSAGE_BODY.
REFRESH IT_MESSAGE.
IT_MESSAGE = 'Please find attached a list test ekpo records'.
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
Regards,
Laxmi. -
Upload excel sheet data through sqlloader into oracle tables
hi everyone,
i am working with excel sheet with following records
8501 Jacob Marshall 15000 21/10/2009 Finance
8502 Chris Campell 50000 13/06/2008 R&D
8503 Simon Dough 50000 3/07/2008 Engineering
8504 Mark Haggai 75000 9/3/2006 Product Management
8505 Verica Beverley 45000 7/2/2008 HR
and i saved it in emp_details.csv
after that when i write following code to make control file
load data
infile 'C:\Documents and Settings\prashant_dabral\Desktop\a.txt'
into table tmp
field terminated by','optionally enclosed by" "
(emp_no,emp_name,salary,doj,dept_name)
after this pl\sqldev returning me error message that ORA-00900:invalid sql statement
can anybody tell me how to resolve issue
or
another method to Upload excel sheet data through sqlloader into oracle tablesA control file is a file located on the operating system, not some SQL or PL/SQL code you try and execute.
Create the control file as a file and then use that to load your data with SQL*Loader from the command line.
http://www.morganslibrary.org/reference/sqlloader.html
Or better still, create it as an external table and then you don't need a seperate control file or need to use sql loader from the command line...
http://www.morganslibrary.org/reference/externaltab.html -
How to convert an excel sheet as pdf and sent mail?
Hi,
I have to open an excel file from report and display a value in a cell, based on that value in excel, macros will automatically trigger and the remaining data will fill in excel sheet.
This sheet i need to convert as pdf and sent as attachment to mail.
Regards,
ShreeHi,
I know how to do with word documents using OLE. But i dont know how to work with Excel sheets.
I have worked on word documents like displaying data in word document from SAP and saving it into local system.
But here my requirement is i need to pass pernr to a cell in an Excel sheet, based on pernr in excel some macros will trigger and fill the details. After that, the filled sheet i need to convert as pdf and sent as mail.
Regards,
Shree. -
Drawing an image in excel sheet using HSSF API
Hi All,
Can any one please help me.
I am facing an issue with excel sheet while drawing image using HSSF API.
I am doing autofit for all the cells i have added. But the image is stretching along with the expanded cells.
I want the autofit option to work but the image should not stretch. Image should be the same size as is but the cells must expand.
Thanks in advanceHi Santosh
You can export the report to PDF
Else you can manually copy the logo\image to excel sheet.
Hope it will help.
Regards
Kultar -
For the first time I cannot open my Excel. The report is saying:image not found, therefor the icon is showing on my desktop.
Before my Mac open with excel sheet, now it is not there anymore. I guess it it hiding somewhere. How to find it? As you can see I am not an IT . Please try to avoid hight tech wording.
Many thanks,
EvaHi Eva,
Open Console in Utilities & see if there are any clues or repeating messages when trying Excel. -
How to move to the next cell in excel sheet
hi,
i am working with excel sheet using cvi. i need to put data in cells for that i have function ExcelRpt_WriteData();
but with this i can give fixed cell range , instead of that is there any function in cvi to point next cell automatically instead of giving cell range we will give intially starting cell range then it has to point to next cell in the sheet. is there any function to do that what i amn expecting.
Thanks & RegardsHello,
Excel Report Generation instrument is built on top of excel2000.fp, the complete ActiveX interface to Excel. excel2000.fp is loaded together with ExcelReport.fp when you run your project, and you should be able to use functions from both instruments in your app (I have not tested it but since ExcelReport is a wrapper of calls to excel2000 instrument, I'm confident it is true).
Given this, you can look at excel2000dem example project that you can find on your disk in samples\activex\excel folder together with excelreportdemo which you may have already studied. In this example there are functions to write to a range of cells addressed by row and col indexes, specifically Excel_RangeSetItem (). This can be a good starting point: there is not the automatic cell advance, but you can address cells individually so you can develop your function according to your needs. Excel2000.fp is a low level interface to Excel: in this respect it is a bit more obscure and requires more effort in use but includes more functions than ExcelReport.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
How do I search for a value in an Excel sheet using ActixeX
I am already accessing my excel sheets however I need to be able to search the sheet for a certain value and return the row/cell location. Is there an activeX control that can do this?
You will need a reference to the range to search. This can be the entire sheet if you wish. Just wire that to the method node Find. Here you can specify all of the typical search options. Wire your string or number into the What input. For the what to LOOKAT value, use -4163 for Value and -4123 for formulas.
The reference returned is the range of the found value. You can wire it into the property node Row and Column to get the location.
Michael Munroe
www.abcdef.biz
Michael Munroe, ABCDEF
Certified LabVIEW Developer, MCP
Find and fix bad VI Properties with Property Inspector
Maybe you are looking for
-
A tip how to make iMovie '08 rescan the iPhoto library for video clips
I could not figure out how to easily force iMovie '08 to rescan all iPhoto library video clips. My problem was that my Casio S880 videos had the audio format DVI ADPCM which is not supported by iMovie '08. I made a script which transcoded all my iPho
-
Parking the document at the time of F-48
Hi SAP Guru's, Is there any facility to park the document at the time of F-48? Is there any way to put an autorisation check. Please help me out. Thanks in advance.
-
Does '.html' HAVE to be a part of the URL?
I want to create a new page to an existing site which will become its own section and want to be able to send/advertise that URL (which will have no ref to the main site & no link to it) eg. www.mainsite.co.uk - I want to advertise: www.mainsite.co.u
-
I updated to ff 19.0. now the upper portion of the browser is not visible! this includes the Firefox button on the left, the minimize, maximize and close button on the right and the open tabs. I know they are still there bc the cursor can go slight a
-
Hiding the command prompt when executing bat file
Hi, I hava a bat file which contains following java -jar MyJar.jar When I execute the bat file, the jar file is executed. But a command prompt also opens along with it. I dont want to display the command prompt to the user. Is there any way to hide t