fs = new POIFSFileSystem(new FileInputStream( "c:\\AAA.xls ")); =====这么写,将路径写死,发现每个用户导入的都是服务器上的EXCEL文件,原来我以为导入的都是用户机器上C盘下的AAA.xls文件,请问如何使每个用户导入他们各自的EXCEL文件?应该怎么写?
以下是POI的源程序:
package poi;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public class POITest {
public static Connection conn = null;
public static Statement stmt = null;
public static boolean connectDB2() {
try {
Class.forName( "org.gjt.mm.mysql.Driver ");
String url = "jdbc:mysql://localhost:3306/dstore ";
conn = DriverManager.getConnection(url, "root ", "111111 ");
stmt = conn.createStatement();
}
//捕获加载驱动程序异常
catch (ClassNotFoundException cnfex) {
System.err.println( "装载JDBC驱动程序失败。 ");
cnfex.printStackTrace();
return false;
}
//捕获连接数据库异常
catch (SQLException sqlex) {
System.err.println( "无法连接数据库 ");
sqlex.printStackTrace();
//System.exit(1); // terminate program
return false;
}
return true;
}
public static boolean readExcelToDB2(String userName) {
POIFSFileSystem fs = null;
HSSFWorkbook wb = null;
try {
fs = new POIFSFileSystem(new FileInputStream( "c:\\AAA.xls ")); =====这么写,将路径写死,发现每个用户导入的都是服务器上的EXCEL文件,原来我以为导入的都是用户机器上C盘下的AAA.xls文件,请问如何使每个用户导入他们各自的EXCEL文件?应该怎么写?
wb = new HSSFWorkbook(fs);
} catch (IOException e) {
e.printStackTrace();
return false;
}
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = null;
HSSFCell cell = null;
String name = " ";
long aa =0;
String company = " ";
long phone =0;
long mobile =0;
String email = " ";
String zu = " ";
int rowNum, cellNum;
int i;