我想通过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