I have created JSPDynpage
component and I am trying to read Excel file using Apache POI 3.2 API.
I have followed the chapter "File Upload" in the guide "Running an Enterprise Portal > Core Development Tasks > HTML-Business for Java" in the SAP Help documentation (formerly http://help.sap.com/saphelp_sm40/helpdata/en/63/9c0e41a346ef6fe10000000a1550b0/frameset.htm).
Error at the line FileInputStream file = new FileInputStream(fp);
(see code below):
#getLocalizedMessage# C:\Documents and Settings\10608871\Desktop\test.xls (The system cannot find the path specified)
I have created the PAR file and deploying it on server.
Thanks in advance.
Aliya Khan.
My code:
try
{
FileUpload fu = (FileUpload)
this.getComponentByName("myfileupload");
// this is the temporary file
if (fu != null) {
// Output to the console to see size and UI.
System.out.println(fu.getSize());
System.out.println(fu.getUI());
// Get file parameters and write it to the console
IFileParam fileParam = fu.getFile();
System.out.println(fileParam);
// Get the temporary file name
File f = fileParam.getFile();
String fileName = fileParam.getFileName();
// Get the selected file name and write it to the console
ivSelectedFileName = fu.getFile().getSelectedFileName();
File fp = new File(ivSelectedFileName);
myLoc.errorT("#fp#"+fp);
try {
FileInputStream file = new FileInputStream(fp); //<============ ERROR HERE
HSSFWorkbook workbook = new HSSFWorkbook(file);
myLoc.errorT("#workbook#"+workbook);
//Get first sheet from the workbook
HSSFSheet sheet = workbook.getSheetAt(0);
myLoc.errorT("#sheet#"+sheet);
//
} catch(Exception ioe) {
myLoc.errorT("#getLocalizedMessage# " + ioe.getLocalizedMessage());
}
i resolved the problem, i was passing the worng parameter instead of f FileInputStream file = new FileInputStream(f);