我已经创建了JSPDynpage
组件,我正在尝试使用Apache POI 3.2 API读取Excel文件。
我遵循了"文件上传"一章。在"运行企业门户"指南中;核心发展任务HTML-Business for javaSAP帮助文档(以前为http://help.sap.com/saphelp_sm40/helpdata/en/63/9c0e41a346ef6fe10000000a1550b0/frameset.htm)。
FileInputStream file = new FileInputStream(fp);
行出错(见下面的代码):
#getLocalizedMessage# C:Documents and Settings10608871Desktoptest.xls(系统找不到指定的路径)
我已经创建了PAR文件并将其部署到服务器上。
提前感谢。
阿里娅汗。我代码:
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());
}
我解决了这个问题,我传递了错误的参数而不是fFileInputStream file = new FileInputStream(f);