Import Data From
Import Data From
1. Create a New Workspace and Project File > New > General > Workspace Configured for Oracle Applications File Name PrajkumarImportxlsDemo
2. ooxml-schemas-1.1.jar http://mvnrepository.com/artifact/org.apache.poi/ooxml-schemas/1.1
3. stax-api-1.0.1.jar http://www.jarfinder.com/index.php/jars/versionInfo/69009
4. log4j-1.2.16.jar http://mvnrepository.com/artifact/log4j/log4j/1.2.16
5. poi-ooxml-schemas-3.7.jar http://mavenhub.com/mvn/central/org.apache.poi/poi-ooxml-schemas/3.7
6. poi-3.7-20101029.jar http://mvnrepository.com/artifact/org.apache.poi/poi/3.7-beta1
7. xmlbeans-2.4.0.jar
http://www.jarfinder.com/index.php/jars/versionInfo/14387
8. dom4j-1.6.1.jar http://grepcode.com/snapshot/repo1.maven.org/maven2/dom4j/dom4j/1.6.1
Steps to add JAR files in Local Machine Right Click on ImportxlsDemo > Project Properties > Libraries > Add jar/Directory and browse to directory where all JAR files have been downloaded and select the JAR files
Click here to know Steps to Add JAR file into R12 server in OA
3. Create a New Application Module (AM) Right Click on ImportxlsDemo > New > ADF Business Components > Application Module Name -- ImportxlsAM Package -- prajkumar.oracle.apps.fnd.importxlsdemo.server Check Application Module Class: ImportxlsAMImpl Generate JavaFile(s)
4. Create Test Table in which we will insert data from *.xlsx file CREATE ( --TABLE -Data xx_import_excel_data_demo -------------------Columns --------------------
column1 column2 column3 column4 column5 ---last_update_date last_updated_by creation_date created_by ); DATE NUMBER DATE NUMBER last_update_login NOT NOT NOT NOT Who
VARCHAR2(100), VARCHAR2(100), VARCHAR2(100), VARCHAR2(100), VARCHAR2(100), -------------------Columns -------------------NULL, NULL, NULL, NULL, NUMBER
5. Create a New Entity Object (EO) Right click on ImportxlsDemo > New > ADF Business Components > Entity Object Name ImportxlsEO Package -- prajkumar.oracle.apps.fnd.importxlsdemo.schema.server Database Objects -- XX_IMPORT_EXCEL_DATA_DEMO
Note By default ROWID will be the primary key if we will not make any column to be primary key
Check the Accessors, Create Method, Validation Method and Remove Method
6. Create a New View Object (VO) Right click on ImportxlsDemo > New > ADF Business Components > View Object Name -- ImportxlsVO Package -- prajkumar.oracle.apps.fnd.importxlsdemo.server
In Step2 in Entity Page select ImportxlsEO and shuttle it to selected list In Step3 in Attributes Window select all columns and shuttle them to selected list
In Java page
Select Generate Java File for View Object Class: ImportxlsVOImpl -> Generate Java File -> Bind Variable Accessors Select Generate Java File for View Row Class: ImportxlsVORowImpl -> Generate Java File -> Accessors
7. Add Your View Object to Root UI Application Module Right click on ImportxlsAM > Edit ImportxlsAM > Data Model > Select ImportxlsVO and shuttle to Data Model list
8. Create a New Page Right click on ImportxlsDemo > New > Web Tier > OA Components > Page Name -- ImportxlsPG Package -- prajkumar.oracle.apps.fnd.importxlsdemo.webui
9. Select the ImportxlsPG and go to the strcuture pane where a default region has been created
Property PageLayoutRN prajkumar.oracle.apps.fnd.importxlsdemo.server.ImportxlsAM Import Data From Excel(*.xlsx) through OAF Page Demo Window Import Data From Excel(*.xlsx) through OAF Page Demo
11. Create messageComponentLayout Region Under Page Layout Region Right click PageLayoutRN > New > Region
Attribute
Property
ID Item Style
MainRN messageComponentLayout
12. Create a New Item messageFileUpload Bean under MainRN Right click on MainRN > New > messageFileUpload Set Following Properties for New Item --
13. Create a New Item Submit Button Bean under MainRN Right click on MainRN > New > messageLayout Set Following Properties for messageLayout --
Attribute ID
Property ButtonLayout
Right Click on PageLayoutRN > Set New Controller Package Name: prajkumar.oracle.apps.fnd.importxlsdemo.webui Class Name: ImportxlsCO
(DataObject)pageContext.getNamedDataObject("MessageFileUpload"); String fileName; try { fileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME"); } catch(NullPointerException ex) { throw new OAException("Please Select a File to Upload", OAException.ERROR); } BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, fileName); try { OAApplicationModule oaapplicationmodule = pageContext.getRootApplicationModule(); Serializable aserializable2[] = {uploadedByteStream}; Class aclass2[] = {BlobDomain.class }; oaapplicationmodule.invokeMethod("ReadExcel", aserializable2,aclass2); } catch (Exception ex) {
throw } } }
new
OAException(ex.toString(),
OAException.ERROR);
(ImportxlsVOImpl)getImportxlsVO1();
ReadExcel(BlobDomain
fileData)
throws
IOException
= = = = i
new
0;
<= = =
row.getLastCellNum();
(NullPointerException
e)
excel_data =
= 0; k
new <
for (int k { j=j+1; try { Cell cell = row.getCell(k); switch { case excel_data[j] break; case if { DateFormat excel_data[j] } else { int resultVar excel_data[j] } break; case excel_data[j] break; case excel_data[j] break; default: excel_data[j] } } catch {
= =
"";
(NullPointerException
e)
"";
(IOException
e)
row i < +i
= excel_data.length;
createRow(); i++)
,excel_data[i]);
e)
15. Congratulation you have successfully finished. Run Your page and Test Your Work
Your Comment: HTML Syntax: NOT allowed Please answer this simple math question 5+5