Reading & writing from MS Excel files in Webdynpro ABAP
Dear experts,
We have a requirement to read and write from an MS excel file in a Webdynpro ABAP based application. The application would be deployed on WAS (Web Application Server) which is running as part of SAP ECC on UNIX platform.
What is not clear is
1) If we store the MS Excel template on the server which has UNIX, will the file be recognised for reading/writing programmatically in Webdynpro ABAP? If this works, we have a requirement where the end users will download the excel template and upload the same after filling data into the excel file. The data filled into the excel has to be read and updated in the SAP backend (ECC).
2) There is an article on "Modifying Excel using WD ABAP" at the following link
https://wiki.sdn.sap.com/wiki/display/WDABAP/ModifyingexistingexcelsheetusingWDABAP
But again it is not clear whether this approach will work on Unix based SAP server (ECC WAS).
Thanks
Suresh
I don't know if there is an application in Unix that can read Excel files - if that is what you are asking. However that has nothing to do with this forum. If you are uploading the file to ABAP using Web Dynpro ABAP, then it doesn't matter what Operating System the server is running on. Unix, Linux, Windows - all the processing is done in ABAP and is OS independent. The actual reading of the file in ABAP involves reading either an XML or Text Tab Delimited version of the Excel file however - if you read through the links on manipulating Excel in ABAP.
Similar Messages
-
Reading data from an excel file
Hi,
I want to read data from the excel file and display it in
jsp page. Iam getting the following error:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =
DriverManager.getConnection("jdbc:odbc:mydsn","","");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from [holidays$]");
Here i have created the dsn with the name "mydsn". I have the
following data in the mydsn.dsn file:
[ODBC]
DRIVER=Microsoft Excel Driver (*.xls)
UID=admin
UserCommitSync=Yes
Threads=3
SafeTransactions=0
ReadOnly=1
PageTimeout=5
MaxScanRows=8
MaxBufferSize=2048
FIL=excel 8.0
DriverId=790
DefaultDir=D:\WorkSpace\Projects\VINET\devl\webroot\jsp
DBQ=D:\WorkSpace\Projects\VINET\devl\webroot\jsp\list_of_holidays_2003.xls
thanks in advance
phani.You might want to look at the POI project (an open source Jakarta sub-project) that allows you to create/modify/read excel files via Java code. That might be more flexible and easier than what you're currently trying to do.
Cheers -
GUI_UPLOAD to read data from an Excel File
Hi Folks,
I'm using FM GUI_UPLOAD to read data from an Excel File. But all I see in the table returned is 1 row with garbage values (special chacaters). Excel Workbook has proper data in the sheet, but its not getting uploaded properly. Sy-subrc is 0.
What could be the reason?
Thanksuse FM : ALSM_EXCEL_TO_INTERNAL_TABLE
See the example program to get from XLS file to Internal table
REPORT ZLWMI151_UPLOAD no standard page heading
line-size 100 line-count 60.
*tables : zbatch_cross_ref.
data : begin of t_text occurs 0,
werks(4) type c,
cmatnr(15) type c,
srlno(12) type n,
matnr(7) type n,
charg(10) type n,
end of t_text.
data: begin of t_zbatch occurs 0,
werks like zbatch_cross_ref-werks,
cmatnr like zbatch_cross_ref-cmatnr,
srlno like zbatch_cross_ref-srlno,
matnr like zbatch_cross_ref-matnr,
charg like zbatch_cross_ref-charg,
end of t_zbatch.
data : g_repid like sy-repid,
g_line like sy-index,
g_line1 like sy-index,
$v_start_col type i value '1',
$v_start_row type i value '2',
$v_end_col type i value '256',
$v_end_row type i value '65536',
gd_currentrow type i.
data: itab like alsmex_tabline occurs 0 with header line.
data : t_final like zbatch_cross_ref occurs 0 with header line.
selection-screen : begin of block blk with frame title text.
parameters : p_file like rlgrap-filename obligatory.
selection-screen : end of block blk.
initialization.
g_repid = sy-repid.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = g_repid
IMPORTING
FILE_NAME = p_file.
start-of-selection.
Uploading the data into Internal Table
perform upload_data.
perform modify_table.
top-of-page.
CALL FUNCTION 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
*& Form upload_data
text
FORM upload_data.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = $v_start_col
I_BEGIN_ROW = $v_start_row
I_END_COL = $v_end_col
I_END_ROW = $v_end_row
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
write:/10 'File '.
ENDIF.
if sy-subrc eq 0.
read table itab index 1.
gd_currentrow = itab-row.
loop at itab.
if itab-row ne gd_currentrow.
append t_text.
clear t_text.
gd_currentrow = itab-row.
endif.
case itab-col.
when '0001'.
t_text-werks = itab-value.
when '0002'.
t_text-cmatnr = itab-value.
when '0003'.
t_text-srlno = itab-value.
when '0004'.
t_text-matnr = itab-value.
when '0005'.
t_text-charg = itab-value.
endcase.
endloop.
endif.
append t_text.
ENDFORM. " upload_data
*& Form modify_table
Modify the table ZBATCH_CROSS_REF
FORM modify_table.
loop at t_text.
t_final-werks = t_text-werks.
t_final-cmatnr = t_text-cmatnr.
t_final-srlno = t_text-srlno.
t_final-matnr = t_text-matnr.
t_final-charg = t_text-charg.
t_final-erdat = sy-datum.
t_final-erzet = sy-uzeit.
t_final-ernam = sy-uname.
t_final-rstat = 'U'.
append t_final.
clear t_final.
endloop.
delete t_final where werks = ''.
describe table t_final lines g_line.
sort t_final by werks cmatnr srlno.
Deleting the Duplicate Records
perform select_data.
describe table t_final lines g_line1.
modify zbatch_cross_ref from table t_final.
if sy-subrc ne 0.
write:/ 'Updation failed'.
else.
Skip 1.
Write:/12 'Updation has been Completed Sucessfully'.
skip 1.
Write:/12 'Records in file ',42 g_line .
write:/12 'Updated records in Table',42 g_line1.
endif.
delete from zbatch_cross_ref where werks = ''.
ENDFORM. " modify_table
*& Form select_data
Deleting the duplicate records
FORM select_data.
select werks
cmatnr
srlno from zbatch_cross_ref
into table t_zbatch for all entries in t_final
where werks = t_final-werks
and cmatnr = t_final-cmatnr
and srlno = t_final-srlno.
sort t_zbatch by werks cmatnr srlno.
loop at t_zbatch.
read table t_final with key werks = t_zbatch-werks
cmatnr = t_zbatch-cmatnr
srlno = t_zbatch-srlno.
if sy-subrc eq 0.
delete table t_final .
endif.
clear: t_zbatch,
t_final.
endloop.
ENDFORM. " select_data -
Help! How to read data from an Excel file?
Hi,
I need to read data from an Excel file that may contain more then one table in a sheet. How can I read them?
I would be eternally grateful to anyone who can give me any information.Did you try POI from Apache?
http://jakarta.apache.org/poi/index.html -
How to read the excel file using webdynpro abap?
Hi,
how to read and modify excel file using webdynpro abap?
Regards,
PavaniFor reading excel file follow the steps :
1. Use a File upload UI element and bind it with xstring.
2. Now your excel will be uploaded and stored in Xstring.
3. Convert Xstring to String data using FM 'HR_KR_XSTRING_TO_STRING'.
4. Now split the string at new line so as to make an internal table .
Ex . SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE it_table.
here it_table is type table of string.
5.now loop at the internal table and separate the content of this table separated by tab.
Ex. SPLIT wa_table AT cl_abap_char_utilities=>horizontal_tab INTO TABLE it_new.
it_new type string_table.
6. For more info , refer this thread :
Re: How to upload excel file in Webdynpro application using ABAP -
How to read data from the excel file using java code.
Hi to all,
I am using below code to getting the data from the excel file but I can't get the corresponding data from the specific file. can anyone give me the correct code to do that... I will waiting for your usefull reply......
advance thanks....
import java.io.*;
import java.sql.*;
public class sample{
public static void main(String[] args){
Connection connection = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbc:odbc:Mydsn","","" );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
System.out.println("sample:"+rs);
ResultSetMetaData rsmd = rs.getMetaData();
System.out.println("samplersd:"+rsmd);
int numberOfColumns = rsmd.getColumnCount();
System.out.println("numberOfColumns:"+numberOfColumns);
while (rs.next()) {
System.out.println("sample1:"+rs);
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1) System.out.print(", ");
String columnValue = rs.getString(i);
System.out.print(columnValue);
System.out.println("");
st.close();
con.close();
} catch(Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}1: What is the name of the excel sheet?
2: What is printed in this program? null ? anything?
error?Excel file name is "sample.xls" I set excel file connectivity in my JDBC driver(DSN). Here in my program I am not giving that excel file name. I am giving only that excel sheet name. that is followed
ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );The output of this program is given bellow.
sample:sun.jdbc.odbc.JdbcOdbcResultSet@1b67f74
samplersd:sun.jdbc.odbc.JdbcOdbcResultSetMetaData@530daa
numberOfColumns:2 -
How read cells from an Excel file?
Hi,
I want to search in the first column of a Excel file a name and when I found it I want to read the near cells (same row but different column).
I try with the Activex but I don't found the rigth solution.
Can I help me, please?
ThanksOk, thanks
Attachments:
Open & read .zip 16 KB
Find_name subvi.zip 28 KB
Read near cell.zip 32 KB -
How to read data from many excel files
I'm aquiring data continusly from several sensors, and every days file name are changed. Data are saved on xls files.
Now, I'd like to read every data from this files and put them in a waveform. How can I concatenate all files and read the values?You probably do not want to use a traditional waveform. LabVIEW has a Waveform Chart which inputs one point at a time. Waveform Graph inputs an array.
I suspect that the data is stored in an array. You need to read the arrays in and build them into larger arrays. If your right click on the build array vi, you can select concantenate which will append one array to the end of the other. When you have built your giant array, just feed it to a waveform graph.
If you need to see some example code, go to the advanced search page. It is at www.ni.com >> support >> advanced search (it is at the botton--click on the words). Enter excel read in the all the words field and search just the example programs. There were for hits.
Jeremy Braden
National Ins
truments -
I want to read and use some informations from a excel file
To test a graphic, i need to take a lot of numbers in a excel file...
but i dont know how to open and read this file but i dont know how...
thx for your help...Hello,
You can open, read, and even write excel files (if you write a file with extension .xls, windows will interpret it as an excel file be default) using the File I/O VIs in LabVIEW. To extract the data, all you really need to realize is that spreadsheets programs like excel store data with the following basic rules:
1. the entire spreadsheet is really just a large string - to read them, you just have to know the data you read is stored based on rules 2 and 3; to write them you just have to conform to rules 2 and 3.
2. cells in a given row are delimited by tabs (usually by default) and sometimes commas (but usually only if you set this specifically in the spreadsheet program)
3. rows are delimited by end of line characters, which will usually be one carriage return and one linefeed character in that order on windows.
In fact, for writing spreadsheet strings (which can be opened in excel) from LabVIEW, check out the Array to Spreadsheet String and Spreadsheet String to Array functions in the String Palette. That is, if you imagine the excel spreadsheet as a 2D array, those functions will essentially convert between the large string, and a 2D array in LabVIEW containing the values you would see in excel's corresponding cells.
I have attached a program that will use the array to spreadsheet string function to write an excel file containing those values - it will be named test.xls and should be on your C: drive directly. A good exercise to get started would be to write a VI using similar (some inverse) functions to read that string, and convert it back to an array.
I hope this helps!
Best Regards,
JLS
Best,
JLS
Sixclear
Attachments:
Simple Write Spreadsheet String to Excel File.vi 25 KB -
Is there any way to read the data from an excel file w/o using a loop structure?
I am retrieving a large amount of data (multiple sheets) from an excel file and would like to extract the entire range without retrieving individual cell values(too slow). I can write an range all at once but cannot read it.
If you are able to write a block of data, then you should be able to read a block. The four requirements that you want to verify are:
1. The Range specified must match the exact size and location of the data block you want to read
2. The returned data is in a 2D array of Variants (either strings or numbers)
3. Use Variant to Data to convert to 2D DBL or 2D Strings
4. Check for the correct orientation for your application (use transpose if it is not)
Michael Munroe
Certified LabVIEW Developer
www.abcdef.biz
Michael Munroe, ABCDEF
Certified LabVIEW Developer, MCP
Find and fix bad VI Properties with Property Inspector -
TIFF-VIs for reading/writing from/to files
To whom it may concern,
I'm looking for TIFF-VIs for reading/writing from/to files
for Labview 6 without any add-on package.
Unfortunately I can't use TiffRd04 and TiffSv05 from
Koji Ohashi due to the different file format!
Any hints?
Thank you in advance. Best regards from Germany
Udo WeikHi Udo,
did you check these TIFF related libraries? .. maybe one of them is working.
Good Luck -
I was wondering, what do i need to look at to get cracking with making a programme that can read from a excel file
I was thinking of making a programme that uses a excel spreadsheet <this spreadsheet is made and provided by the national lottery and has all the winning combinations that have been drawn in past draws> and reading them in and generating a list of combinations that have not occured yet
Its just for a bit of fun, but could be a good challenege
thanksPaulOckleford wrote:
If all you want to do is select from the excel sheet you may find it easier to use the jdbc option, I have an example of some code I wrote that does a select from an excel sheet and it may be useful for you:Just my opinion here but I would avoid using odbc to deal with the spreadsheet if at all possible.
Time for a war story:
After losing an argument with some business, marketng and management I had to develop a program that accepted spreadsheets as datafiles and it was nothing but trouble.
I experienced all kinds of type problems, the most common and annoying of them being
that the driver (via some logic unknown to me) will determine the type of each column.
Any data that is does not match that expectation is dropped (I found that the query returned NULL).
As far as I could tell there was no way to make the driver treat the data the way you want it too.
After much trouble and lots of manual intervention by the poor person who has to deal with this data on a regular basis it seems to be working but it was not fun it is still very ugly code.
You may not end up reliving my tale of woe, but I though I would give you some fair warning.
As I continue to say "Spreadsheets are not a reasonable data transfer format." -
Read a Column from an Excel file
Guys,
Is there a way I can read a specific column from an excel file, use that data to query and select data from a table and then insert the output into another column of that same excel file.
Please advise! Thanks> Is there a way I can read a specific column from an excel file, use that data to query and select data from a
table and then insert the output into another column of that same excel file.
Not easily. An Excel file is typically in a proprietary binary file format. Perhaps saved using the new MS Office XML format.. which would be possible to process via Oracle's XDB.
But assuming it is in a binary format, you need "something else" to read and parse that file for you - like ODBC or DDE or COM/DCOM, etc.
Oracle supports Heterogeneous Database Services. On a Windows Server, you can create a database link in Oracle that uses an ODBC driver to connect to an ODBC data source. There are ODBC drivers for Excel. However, this requires the data in the worksheet to be properly marked as a data table. Or did last time I looked at it about 2 years ago.
You can also call external "interfaces" from PL/SQL using EXTPROC - such interfaces can be DLLs. Which means you do have access to the Win32 API and application APIs from PL/SQL. This can be used to access the content of an Excel file - DDE for example can quite easily do this (you use it to peek the contents of an Excel grid location), but requires Excel to be running and that spreadsheet to be loaded. DDE can also be used to poke contents (write something back to a cell in a spreadsheet).
But using Oracle code to use an Excel file as a kind of database file... that IMO does not make a lot of sense. At all. -
How to retrieve data from an Excel file which is located on server
hi everybody,
I am using SAP NWDS 2004s .
I have done an application on how to export the table data into an Excel .
Now i want to get the data from an Excel file which is located in server and display that data which is in excel in a View for example a Sample view in Webdynpro .
In Sample view i took a uielement textview to display the data ....
can any one help how to procced further
Thanks in advance
MadhaviOptions to read Excel data to WebDynpro context
Reading Excel Sheet from Java without using any Framework
Reading Multiple Sheets of Excel Sheet from Java
Few Threads
How to Display the content of Excel file into Webdynpro Table
Is it possible to upload data from excel file(.xls)
Re: How to export the data as integer into excel sheet?
regards
Vinod -
How to Display the content of Excel file into Webdynpro Table
Hi Experts
I am following the Blog to upload a file in to the webdynpro context,but my problem is after uploading a excel file i need to extract the content from that Excel file and that content should be displayed in the webdynpro table.Can any body please guide me how to read the content from excel and to Display in the Table.
Thanks and Regards
KalyanHI,
Take for example, if Excel file contains 4 fields,
Add jxl.jar to JavaBuild path and Use this snippet
File f=new File("sample.xls");
Workbook w=Workbook.getWorkbook(f);
Sheet sh=w.getSheet(0);
int cols=sh.getColumns();
int rows=sh.getRows();
Cell c=null;
String s1=null;
String s2=null;
String s3=null;
String s4=null;
ArrayList al=new ArrayList();
int j=0;
for(int i=1;i<rows;i++)
ITableElement table=wdContext.createTableElementz
s1=sh.getCell(0,i).getContents();
s2=sh.getCell(1,i).getContents();
s3=sh.getCell(2,i).getContents();
s4=sh.getCell(3,i).getContents();
table.setName(s1);
table.setAddress(s2);
table.setDesignation(s3);
table.setDummy(s4);
al.add(j,table);
j++;
wdContext.nodeTable().bind(al);
Regards
LakshmiNarayana
Maybe you are looking for
-
Garageband 4.1.2 on OS X 10.5.8 freezes
My garageband 4.1.2 on OS X 10.5.8 freezes after I press the play button. What version can I use?
-
Formatting issues in iBooks on the iPad
Hello, I'm creating iBooks to publish on the iBookstore, but am having some formatting issues, or so I think at least. I have already created one iBook (http://itunes.apple.com/gb/book/id387336687, apologies for the morbid subject matter), which I te
-
I will preface this by saying that this is probably a stupid question. I am pretty much an Oracle newbie, but I'm constantly trying to learn stuff. I have done a lot of reading on this topic, so I definitely have my own opinion, but everybody in my o
-
Regarding my payment information made extra
i buy a song from itunes store ,the song cost is 15 rs the thing is it deducted 60+15 total 75
-
How do I resize a graph?
Hello, how do I resize a graph? From what I can see, I can only set its size when I create it? I guess I could Transform > Scale an existing graph - but I'd rather set a fixed width and height so I can keep the proportions right for when I import the