我想通过HTTP请求将数据导出到Excel文件。我有一个实现请求处理程序接口的类。
我将响应正文设置为类似header1 \t header2 \t \n content1 \t content2 \t \n
的内容
内容类型为application/msexcel; charset=iso-8859-2
,并且Content-Disposition
设置为attachment; filename=Excel.xls
此方法对于服务器端Javascript应用程序效果很好,但是在ABAP中进行相同操作时,创建的Excel文件完全没有列或行,整个excel格式的响应正文字符串都插入到一个单元格中。
有人知道,JS和ABAP有什么区别?
感谢和最好的问候!
我使用此示例:
* list1 is an internal table
loop at list1 INTO wa .
CONCATENATE output WA-weekday WA-x WA-DTEXT
WA-SCHKZ WA-BEGTM WA-ENDTM
CL_ABAP_CHAR_UTILITIES=>CR_LF
INTO output SEPARATED BY TAB .
endloop.
* utf-16le , format for excel file
app_type1 = 'APPLICATION/MSEXCEL;charset=utf-16le'.
* convert string to xstring
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = output
mimetype = 'APPLICATION/MSEXCEL;charset=utf-16le'
IMPORTING
buffer = l_xstring.
CONCATENATE cl_abap_char_utilities=>byte_order_mark_little
l_xstring
INTO l_xstring IN BYTE MODE.
CALL METHOD cl_bsp_utility=>download
EXPORTING
object_s = l_xstring
content_type = app_type
content_disposition = 'attachment;filename=webforms.xls'
response = response
navigation = navigation.
您还可以在sdn中看到此线程:http://scn.sap.com/people/thomas.jung/blog/2004/08/09/bsp-download-to-excel-in-unicode-format