on 2012 Mar 15 2:38 PM
Hello experts,
I'm having a problem with downloading .docx and .xlsx files from Webdynpro.
Situation: User uploads a document and it is saved to the network drive. Later on a user must be able to open this file/download this file in Webdynpro ABAP. To read the file into an XSTRING I use the statement:
OPEN DATASET x FOR INPUT IN BINARY MODE
This is succesfull, later on I retrieve the correct MIME type and size
FYI: With note 1237688 you can retrieve the latest Word 2007 mime types in your system
CALL FUNCTION 'SDOK_MIMETYPE_GET'
EXPORTING
extension = lv_extension
IMPORTING
mimetype = lv_mime_type.
XSTRLEN( ls_attachment-file_contents ).
For example .docx is mime type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Afterwards I pass these on to the FileDownload UI element or the following method
CL_WD_RUNTIME_SERVICES=>attach_file_to_response
Result: .docx or .xlsx download files are always corrupt - with Office 2010 you do have the option to try and recover the file -> and this works!
But our customer is using Office 2007 and this is not supported there so he only gets the message that the file is corrupt.
Can anyone else confirm this problem or help me with a solution? Thx!
Greetings,
Wouter
DATA: lt_access_info TYPE TABLE OF sdokfilaci,
lt_ascii_content TYPE TABLE OF sdokcntasc,
lt_binary_content TYPE TABLE OF sdokcntbin.
DATA: lv_doc_lenght TYPE i,
lv_qty_lines TYPE i,
lv_xstring TYPE xstring.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = w_object_id
raw_mode = 'X'
TABLES
file_access_info = lt_access_info
file_content_ascii = lt_ascii_content
file_content_binary = lt_binary_content
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
RETURN.
ENDIF.
FIELD-SYMBOLS: <lt_access_info> LIKE LINE OF lt_access_info.
READ TABLE lt_access_info ASSIGNING <lt_access_info> INDEX 1.
IF sy-subrc IS INITIAL AND <lt_access_info>-file_size IS NOT INITIAL.
lv_doc_lenght = <lt_access_info>-file_size.
ELSE.
lv_qty_lines = lines( lt_binary_content ).
lv_doc_lenght = lv_qty_lines * 1022.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please use below class's method to generate XSTRING
cl_fdt_xl_spreadsheet=>if_fdt_doc_spreadsheet~create_document(
EXPORTING
itab = lr_data "(reference to the internal table to be printed)
iv_call_type = 2
columns = lt_column "(Column table)
RECEIVING
xdocument = lv_xstring ).
To populate lt_column, you can use LVC_FIELDCATALOG_MERGE FM. After lt_column is filled you need to populate it's additional parameters as below-
* Creating XLSX spreadsheet field list
LOOP AT lt_fieldcat INTO ls_fieldcat.
CLEAR ls_column.
ls_column-id = sy-tabix.
ls_column-name = ls_fieldcat-fieldname.
ls_column-is_result = abap_true.
* Getting the field information for excel field
lr_string ?= cl_abap_datadescr=>describe_by_data( ls_fieldcat-fieldname ).
ls_column-type = lr_string.
* Reading the field label from structure's label
ls_column-display_name = <description text here>. "text
APPEND ls_column TO lt_column.
ENDLOOP.
I hope this works for XLSX, it worked for me. The only disappointment is, it takes some extra time.
Thanks
Mohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can choose this option if the issue is minor. It can repair Word documents without affecting their original formatting. This Word File Recovery Tool to Repair Damaged Word DOC, DOCX, DOT, DOTX, DOCM, and DOTM Files Formats software proves its reliability with its intuitive and DIY interface to make the process of docx/doc file repair smooth like never before. You don’t need any professional assistance to operate it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
i have a similar Problem.
When i Export my Report to an Excel File i can not open the file because of corrupt data.
Is this an Problem of Excel or the Export function of sap?
How can i fix this Problem without repair and recover Systems?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Repair and Recover Corrupt Word and Excel file, you should try Word and Excel article which easily read and get solution from corrupt Word and Excel file.
Common Reasons Of Excel Corruption And How To Repair Corrupt Microsoft Excel File? by Steve Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Wouter,
Did you had any luck in resolving this issue? We are on the same boat and would help if you could share some thoughts.
Thanks,
Nagarajan.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please see if my solution http://scn.sap.com/thread/3323886 helps.
'get_mimetype_by_file_ext' method is actually a call to 'SDOK_MIMETYPE_GET' FM.
Regards,
Omri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peeters,
I had a simliar issues too i was getting the files as corrupeted when using docs or xlsx file extension. Then in the attach_file_to_response. i provided the file name with .doc and xls and it worked.
Best regards,
Arun Krishnamoorthy
9967166102
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's the point, the specified MIME type has to match with content. Some browsers do not look at the MIME type, only the file suffix. Office 2007 has to be installed on the client in order to be able to open the Office 2007 documents. Also make sure compression at any point (AS ABAP, proxies, etc) is not corrupting the file. Use Firefox's HttpFox to verify that the content sent from AS ABAP matches with the content received in the browser.
Hi Wouter Peeters,
I've the exact same problem with office 2007 files.
Did you manage to solve the problem? if yes, can you please share the solution?
Regards,
Omri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please try anyone or both solution
Read more : http://msofficerecovery.blogspot.com/2014/04/use-third-party-tools-for-flawless-excel-recovery.html
User | Count |
---|---|
81 | |
11 | |
10 | |
10 | |
10 | |
8 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.