on 10-11-2010 9:46 PM
Hi All,
Can anybody please let me know how to upload the .xls file in the webdynpro ABAP.I serached in any forums but eveybody is saying that conver it to .txt file.
I am able to upload .csv and .txt files in WDABAP not the .xlsfile directly.I serac
Thanks,
taragini
Upload XLS to ABAP and access content of file.
1) cannot be done.
2) in case you are confused - please refer to point 1.
This topic has come up so many times in this forum it is tiresome - XLS is a proprietary binary format of Microsoft - you cannot decode and read it in ABAP.
there is an XLSX to ABAP converter that is in the early stages of development - but XLS cannot be read.
Tangcan - please! the code you are quoting does not work for this use case - have you ever seen it work or are you just copy/pasting from some of the other forums? It is good for displaying a tab separated file with 3 fields. NOT an Excel XLS file.
Sorry for ranting so - but really this sort of question and answer should not be part of this forum.
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, i am sorry to make you confuse.
I can say: the above coding is complete right, and written by meself, not copy from other places or forums.
In my real project , i have one task which is to read the content of EXCEL file.
And, my solution is just what i said in this thread above.
So, i can promise: the coding is right, and can work fine and right.
In fact, i have summaried this case in my book. You can check the following URL link:
http://space.itpub.net/17144169/viewspace-674655
However , it is written by Chinese.I am not sure whether it can help or not.
In addition, if i made the mistake to understand "tarangini katta"'s requirement, pls forgive, very sorry for that.
I just said out my experience .
And, very glad to discuss with you, my good friends.
Best wishes.
Thanks for the clarification Tangcan,
but this code will not work for reading an XLS file - a tab separated file Yes - indeed it is very nice code for that! Sorry for getting upset - it's just the number of posts where we see people posting that XLS can be converted into a readable format by just using some xstring to string conversion utility is disheartening!
Chris
Very sorry for my miss.
yes, i have forgotten one VERY VERY important note: The user should save the XLS into Horizonal-tab separated file first.
About reading the XLS directly, there are so many discussion and post in this forum.
What i post in this thread is just what i have done about this topic in my real project, and i summaried it simply.
Eventually, very glad to discuss with you, so experienced expert. I can learn so much from what you taught.
Thanks very much.
I have a ALV (WD-ABAP ) table and the user will be downloading the data to excel using "Export to Microsoft Excel" option. They will then save the file on the desktop and make some modifications. Now they should be able to upload the data back into the ALV table.
If i understand the above thread correctly, this is not possible. Am i right? Can you please correct me if i am wrong?
Is it possible to read the data back if they save the file in some other format other than the default .XLS ?
I am following the link [http://wiki.sdn.sap.com/wiki/display/WDABAP/ExcelFileUploadAndDisplayDataUsingWebDynPro+ABAP
But somehow the variable is having the values as below (could not post the complete text due to some error on SDN. Not sure where from it is reading this data. My file name is export.xls
" MIME-Version: 1.0##X-Document-Type: Worksheet................"
Regards,
Aditya.
Edited by: Aditya Atluri on Nov 8, 2010 9:49 PM
Edited by: Aditya Atluri on Nov 8, 2010 9:52 PM
The file format used by the ALV export to Excel functionality is XML not XLS.
You can read the data in this file by using an XML transformation. (not the easiest to do, but certainly do-able - as opposed to reading an XLS formatted file) This XML format was a precursor to the XLSX format used by later versions of MS Excel.
It doesn't matter what the file is called - rename a image file as as image.doc and it will still be a image file.
What's in a name? that which we call a rose
By any other name would smell as sweet;
The same thing with an MS Excel file - just changing the name does not change the content.
MS Excel has some "smarts" in that it will check the file format of a document and open it correctly - save a comma separated file "data.csv" and rename it "data.xls" and Excel will still open it... With XML --> XLS rename it doesn't even prompt you that the file is different.
So perhaps I should rephrase my "THIS WILL NOT WORK" statement
if the file is formatted as XLS (not just named XLS) then you cannot read it in ABAP (Web Dynpro or otherwise).
Hope this clarifies things.
Cheers.
Chris
It's easy to upload EXCEL file using WD4A.
The following is a simple summary, you can Google them for detail if neccesary.
(1). Define one Context attribute,for example you can name it as "DATASOURCE". In addition , you can define one node named "table" to hold the information of your EXCEL. pls take attention to the format/structure.
(2).Using the UI element "FileUpload", then bind the property "data" to the context attribute declared in 1st step.
Off course, maybe you need one button name "Upload" to trigger the action which will upload the EXCEL.
(3).in the action of the button(or anyother action only if you use it to upload), using the following example code:
method ONACTIONUPLOAD .
DATA:
lo_Node type ref to If_Wd_Context_Node,
lo_Elem type ref to If_Wd_Context_Element,
lw_datasour type xstring,
lw_string type string,
lt_data type TABLE OF string,
lt_field type TABLE OF string,
lv_field TYPE string,
ls_context type wd_this->element_TABLE,
lt_context type wd_this->elements_TABLE .
* get the datasource Xstring
wd_context->get_attribute(
EXPORTING
name = 'DATASOURCE'
IMPORTING
value = lw_datasour ).
* convert the XString ==> string
* CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
* EXPORTING
* IM_XSTRING = lw_datasour
* IM_ENCODING = 'UNICODE'
* IMPORTING
* EX_STRING = lw_string.
DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE.
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
INPUT = lw_datasour
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = conv.
conv->READ( importing data = lw_string ).
* get the data of file
split lw_string at cl_abap_char_utilities=>newline into TABLE lt_data.
* delete the header
DELETE lt_data INDEX 1.
* get all the field name
LOOP AT lt_data into lw_string.
SPLIT lw_string at cl_abap_char_utilities=>horizontal_tab into table lt_field.
***get all the 3 fields of one line
READ TABLE lt_field INTO lv_field INDEX 1.
ls_context-carrid = lv_field.
READ TABLE lt_field INTO lv_field INDEX 2.
ls_context-connid = lv_field.
READ TABLE lt_field INTO lv_field INDEX 3.
ls_context-text = lv_field.
append ls_context to lt_context.
ENDLOOP.
* bind table
lo_node = wd_context->get_child_node( 'TABLE' ).
lo_node->bind_table( lt_context ).
endmethod.
Best wishes~
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.