struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.multipart.maxSize" value="20971520" /> <!-- 20MB -->
<constant name="struts.multipart.saveDir" value="E:\"></constant>
<constant name="struts.i18n.encoding" value="GBK" /><!-- internationalization -->
<package name="struts2" extends="struts-default">
<action name="upload" class="com.poi.read.UploadAction">
<result name="success">success.jsp</result>
<result name="input">upload.jsp</result>
</action>
<action name="download"
class="com.poi.write.DownloadAction">
<result name="success" type="stream">
<param name="contentType"> application/vnd.ms-excel</param>
<param name="contentDisposition">filename="Struts2.rar"</param>
<param name="inputName">downloadFile</param>
</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
10 个解决方案
#1
是不是利用poi导出?
#2
是的。我是用struts2+POI POI 用HSSFWorkbook去创建Book.
#3
HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.
.xls 和 .xlsx 好像使用的类都不一样
.xls 和 .xlsx 好像使用的类都不一样
#5
如楼上所说
97-2003使用HSSFWorkBook
2007使用XSSFWorkbook
实现方法不一样,不是改配置就完事得
97-2003使用HSSFWorkBook
2007使用XSSFWorkbook
实现方法不一样,不是改配置就完事得
#6
不好意思,我刚才写错了,我确实是用XSSFWorkbook类去创建BOOK的。XSSFWorkbook 是对excel2007的处理。而HSSFWorkBook是对excel2003的处理。 问题是我用了XSSFWorkbook,还是不能处理excel2007.
原因在于struts.xml配置文件里的contentType
<param name="contentType">application/vnd.ms-excel</param>
这个只支持excel2003.不支持excel2007。
// 先创建工作簿对象
XSSFWorkbook workbook2007 = new XSSFWorkbook();
// 创建工作表对象并命名
XSSFSheet sheet = workbook2007.createSheet("学生信息统计表");
//.........................
// 设置行列的默认宽度和高度
sheet.setColumnWidth(0, 32 * 100);// 对A列设置宽度为100像素
sheet.setColumnWidth(1, 32 * 120);
sheet.setColumnWidth(2, 32 * 140);
sheet.setColumnWidth(3, 32 * 160);
sheet.setColumnWidth(4, 32 * 180);
#7
不好意思,我刚才写错了,我确实是用XSSFWorkbook类去创建BOOK的。XSSFWorkbook 是对excel2007的处理。而HSSFWorkBook是对excel2003的处理。 问题是我用了XSSFWorkbook,还是不能处理excel2007.
原因在于struts.xml配置文件里的contentType
<param name="contentType">application/vnd.ms-excel</param>
这个只支持excel2003.不支持excel2007。
#8
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
#9
谢谢8楼,正解
#10
//导入普通客户信息
public String importExcle(){
System.out.println("------------");
TEmployee employee = (TEmployee) request.getSession().getAttribute("employee");
TCustomerInfo c=new TCustomerInfo();
// 声明数据流
InputStream is = null;
if(excel!=null){
try {
// 解析excel 2007 版本文件
is = new FileInputStream(excel);
XSSFWorkbook work = new XSSFWorkbook(is);
XSSFSheet sheet = work.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
// 循环表的行,从第二行开始
for (int i = 1; i < rows; i++) {
c = new TCustomerInfo();
XSSFRow row = sheet.getRow(i);
if (row == null) {//判断是否为空
continue;
}
// 读取该行的每一列
for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
XSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
if (cell.toString() == null || "".equals(cell.toString())) {
continue;
}
System.out.println(" 解析excel 2007 版本文件");
switch (j) {// 通过列数来判断对应插如的字段
case 0:
System.out.println("setCompanyName="+cell.getStringCellValue());
c.setCompanyName(cell.getStringCellValue());
break;
case 1:
System.out.println("setLinkName="+cell.getStringCellValue());
c.setLinkName(cell.getStringCellValue());
break;
case 2:
System.out.println("setTell="+cell.getStringCellValue());
c.setTell(cell.getStringCellValue());
break;
case 3:
System.out.println("setTelephone="+new BigDecimal(cell.getNumericCellValue()).toPlainString());
c.setTelephone(String.valueOf(new BigDecimal(cell.getNumericCellValue()).toPlainString()));
break;
case 4:
System.out.println("setPosition="+cell.getStringCellValue());
c.setPosition( cell.getStringCellValue());
break;
case 5:
System.out.println("setEmail="+cell.getStringCellValue());
c.setEmail( cell.getStringCellValue());
break;
case 6:
System.out.println(cell.getStringCellValue());
c.setCompanyType( cell.getStringCellValue());
break;
case 7:
System.out.println("setCustomerType="+cell.getStringCellValue());
c.setCustomerType( cell.getStringCellValue());
break;
case 8:
System.out.println("setCompanyDetail="+cell.getStringCellValue());
c.setCompanyDetail( cell.getStringCellValue());
break;
}
c.setCreateMan(employee.getName());
c.setCreateDate(new Date());
}
customerInfoBiz.addCustomer(c);
}
} catch (Exception e) {
System.out.println("=========================");
//e.printStackTrace();
System.out.println("进入 ---解析excel 2003 版本文件--错误抛出");
try {
// 解析excel 2003 版本文件
is = new FileInputStream(excel);
HSSFWorkbook work = new HSSFWorkbook(is);
HSSFSheet sheet = work.getSheetAt(0);
if (sheet != null) {
System.out.println("解析excel 2003 版本文件");
int rows = sheet.getPhysicalNumberOfRows();
// 循环表的行,从第二行开始
for (int i = 1; i < rows; i++) {
c = new TCustomerInfo();
HSSFRow row = sheet.getRow(i);
if (row == null) {//判断是否为空
continue;
}
// 循环表格的列
System.out.println("row.getPhysicalNumberOfCells()=-========"+row.getPhysicalNumberOfCells());
for (short j = 0; j < row.getPhysicalNumberOfCells(); j++) {
HSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
if (cell.toString() == null || "".equals(cell.toString())) {
continue;
}
switch (j) {// 通过列数来判断对应插如的字段
case 0:
System.out.println("setCompanyName="+cell.getStringCellValue());
c.setCompanyName(cell.getStringCellValue());
break;
case 1:
System.out.println("setLinkName="+cell.getStringCellValue());
c.setLinkName(cell.getStringCellValue());
break;
case 2:
System.out.println("setTell="+cell.getStringCellValue());
c.setTell(cell.getStringCellValue());
break;
case 3:
System.out.println("setTelephone="+new BigDecimal(cell.getNumericCellValue()).toPlainString());
c.setTelephone(String.valueOf(new BigDecimal(cell.getNumericCellValue()).toPlainString()));
break;
case 4:
System.out.println("setPosition="+cell.getStringCellValue());
c.setPosition( cell.getStringCellValue());
break;
case 5:
System.out.println("setEmail="+cell.getStringCellValue());
c.setEmail( cell.getStringCellValue());
break;
case 6:
System.out.println(cell.getStringCellValue());
c.setCompanyType( cell.getStringCellValue());
break;
case 7:
System.out.println("setCustomerType="+cell.getStringCellValue());
c.setCustomerType( cell.getStringCellValue());
break;
case 8:
System.out.println("setCompanyDetail="+cell.getStringCellValue());
c.setCompanyDetail( cell.getStringCellValue());
break;
}
c.setCreateMan(employee.getName());
c.setCreateDate(new Date());
}
customerInfoBiz.addCustomer(c);
}
request.setAttribute("message", "导入成功(=^_^=)");
}
} catch (Exception e1) {
request.setAttribute("message", "导入失败,请注意导入格式!!");
e1.printStackTrace();
}
}
}
// 查询时对象中含有值对查询有误
if (customer != null) {
customer = null;
}
return customerList();
}
public String importExcle(){
System.out.println("------------");
TEmployee employee = (TEmployee) request.getSession().getAttribute("employee");
TCustomerInfo c=new TCustomerInfo();
// 声明数据流
InputStream is = null;
if(excel!=null){
try {
// 解析excel 2007 版本文件
is = new FileInputStream(excel);
XSSFWorkbook work = new XSSFWorkbook(is);
XSSFSheet sheet = work.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
// 循环表的行,从第二行开始
for (int i = 1; i < rows; i++) {
c = new TCustomerInfo();
XSSFRow row = sheet.getRow(i);
if (row == null) {//判断是否为空
continue;
}
// 读取该行的每一列
for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
XSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
if (cell.toString() == null || "".equals(cell.toString())) {
continue;
}
System.out.println(" 解析excel 2007 版本文件");
switch (j) {// 通过列数来判断对应插如的字段
case 0:
System.out.println("setCompanyName="+cell.getStringCellValue());
c.setCompanyName(cell.getStringCellValue());
break;
case 1:
System.out.println("setLinkName="+cell.getStringCellValue());
c.setLinkName(cell.getStringCellValue());
break;
case 2:
System.out.println("setTell="+cell.getStringCellValue());
c.setTell(cell.getStringCellValue());
break;
case 3:
System.out.println("setTelephone="+new BigDecimal(cell.getNumericCellValue()).toPlainString());
c.setTelephone(String.valueOf(new BigDecimal(cell.getNumericCellValue()).toPlainString()));
break;
case 4:
System.out.println("setPosition="+cell.getStringCellValue());
c.setPosition( cell.getStringCellValue());
break;
case 5:
System.out.println("setEmail="+cell.getStringCellValue());
c.setEmail( cell.getStringCellValue());
break;
case 6:
System.out.println(cell.getStringCellValue());
c.setCompanyType( cell.getStringCellValue());
break;
case 7:
System.out.println("setCustomerType="+cell.getStringCellValue());
c.setCustomerType( cell.getStringCellValue());
break;
case 8:
System.out.println("setCompanyDetail="+cell.getStringCellValue());
c.setCompanyDetail( cell.getStringCellValue());
break;
}
c.setCreateMan(employee.getName());
c.setCreateDate(new Date());
}
customerInfoBiz.addCustomer(c);
}
} catch (Exception e) {
System.out.println("=========================");
//e.printStackTrace();
System.out.println("进入 ---解析excel 2003 版本文件--错误抛出");
try {
// 解析excel 2003 版本文件
is = new FileInputStream(excel);
HSSFWorkbook work = new HSSFWorkbook(is);
HSSFSheet sheet = work.getSheetAt(0);
if (sheet != null) {
System.out.println("解析excel 2003 版本文件");
int rows = sheet.getPhysicalNumberOfRows();
// 循环表的行,从第二行开始
for (int i = 1; i < rows; i++) {
c = new TCustomerInfo();
HSSFRow row = sheet.getRow(i);
if (row == null) {//判断是否为空
continue;
}
// 循环表格的列
System.out.println("row.getPhysicalNumberOfCells()=-========"+row.getPhysicalNumberOfCells());
for (short j = 0; j < row.getPhysicalNumberOfCells(); j++) {
HSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
if (cell.toString() == null || "".equals(cell.toString())) {
continue;
}
switch (j) {// 通过列数来判断对应插如的字段
case 0:
System.out.println("setCompanyName="+cell.getStringCellValue());
c.setCompanyName(cell.getStringCellValue());
break;
case 1:
System.out.println("setLinkName="+cell.getStringCellValue());
c.setLinkName(cell.getStringCellValue());
break;
case 2:
System.out.println("setTell="+cell.getStringCellValue());
c.setTell(cell.getStringCellValue());
break;
case 3:
System.out.println("setTelephone="+new BigDecimal(cell.getNumericCellValue()).toPlainString());
c.setTelephone(String.valueOf(new BigDecimal(cell.getNumericCellValue()).toPlainString()));
break;
case 4:
System.out.println("setPosition="+cell.getStringCellValue());
c.setPosition( cell.getStringCellValue());
break;
case 5:
System.out.println("setEmail="+cell.getStringCellValue());
c.setEmail( cell.getStringCellValue());
break;
case 6:
System.out.println(cell.getStringCellValue());
c.setCompanyType( cell.getStringCellValue());
break;
case 7:
System.out.println("setCustomerType="+cell.getStringCellValue());
c.setCustomerType( cell.getStringCellValue());
break;
case 8:
System.out.println("setCompanyDetail="+cell.getStringCellValue());
c.setCompanyDetail( cell.getStringCellValue());
break;
}
c.setCreateMan(employee.getName());
c.setCreateDate(new Date());
}
customerInfoBiz.addCustomer(c);
}
request.setAttribute("message", "导入成功(=^_^=)");
}
} catch (Exception e1) {
request.setAttribute("message", "导入失败,请注意导入格式!!");
e1.printStackTrace();
}
}
}
// 查询时对象中含有值对查询有误
if (customer != null) {
customer = null;
}
return customerList();
}
#1
是不是利用poi导出?
#2
是的。我是用struts2+POI POI 用HSSFWorkbook去创建Book.
#3
HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.
.xls 和 .xlsx 好像使用的类都不一样
.xls 和 .xlsx 好像使用的类都不一样
#4
#5
如楼上所说
97-2003使用HSSFWorkBook
2007使用XSSFWorkbook
实现方法不一样,不是改配置就完事得
97-2003使用HSSFWorkBook
2007使用XSSFWorkbook
实现方法不一样,不是改配置就完事得
#6
不好意思,我刚才写错了,我确实是用XSSFWorkbook类去创建BOOK的。XSSFWorkbook 是对excel2007的处理。而HSSFWorkBook是对excel2003的处理。 问题是我用了XSSFWorkbook,还是不能处理excel2007.
原因在于struts.xml配置文件里的contentType
<param name="contentType">application/vnd.ms-excel</param>
这个只支持excel2003.不支持excel2007。
// 先创建工作簿对象
XSSFWorkbook workbook2007 = new XSSFWorkbook();
// 创建工作表对象并命名
XSSFSheet sheet = workbook2007.createSheet("学生信息统计表");
//.........................
// 设置行列的默认宽度和高度
sheet.setColumnWidth(0, 32 * 100);// 对A列设置宽度为100像素
sheet.setColumnWidth(1, 32 * 120);
sheet.setColumnWidth(2, 32 * 140);
sheet.setColumnWidth(3, 32 * 160);
sheet.setColumnWidth(4, 32 * 180);
#7
不好意思,我刚才写错了,我确实是用XSSFWorkbook类去创建BOOK的。XSSFWorkbook 是对excel2007的处理。而HSSFWorkBook是对excel2003的处理。 问题是我用了XSSFWorkbook,还是不能处理excel2007.
原因在于struts.xml配置文件里的contentType
<param name="contentType">application/vnd.ms-excel</param>
这个只支持excel2003.不支持excel2007。
#8
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
#9
谢谢8楼,正解
#10
//导入普通客户信息
public String importExcle(){
System.out.println("------------");
TEmployee employee = (TEmployee) request.getSession().getAttribute("employee");
TCustomerInfo c=new TCustomerInfo();
// 声明数据流
InputStream is = null;
if(excel!=null){
try {
// 解析excel 2007 版本文件
is = new FileInputStream(excel);
XSSFWorkbook work = new XSSFWorkbook(is);
XSSFSheet sheet = work.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
// 循环表的行,从第二行开始
for (int i = 1; i < rows; i++) {
c = new TCustomerInfo();
XSSFRow row = sheet.getRow(i);
if (row == null) {//判断是否为空
continue;
}
// 读取该行的每一列
for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
XSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
if (cell.toString() == null || "".equals(cell.toString())) {
continue;
}
System.out.println(" 解析excel 2007 版本文件");
switch (j) {// 通过列数来判断对应插如的字段
case 0:
System.out.println("setCompanyName="+cell.getStringCellValue());
c.setCompanyName(cell.getStringCellValue());
break;
case 1:
System.out.println("setLinkName="+cell.getStringCellValue());
c.setLinkName(cell.getStringCellValue());
break;
case 2:
System.out.println("setTell="+cell.getStringCellValue());
c.setTell(cell.getStringCellValue());
break;
case 3:
System.out.println("setTelephone="+new BigDecimal(cell.getNumericCellValue()).toPlainString());
c.setTelephone(String.valueOf(new BigDecimal(cell.getNumericCellValue()).toPlainString()));
break;
case 4:
System.out.println("setPosition="+cell.getStringCellValue());
c.setPosition( cell.getStringCellValue());
break;
case 5:
System.out.println("setEmail="+cell.getStringCellValue());
c.setEmail( cell.getStringCellValue());
break;
case 6:
System.out.println(cell.getStringCellValue());
c.setCompanyType( cell.getStringCellValue());
break;
case 7:
System.out.println("setCustomerType="+cell.getStringCellValue());
c.setCustomerType( cell.getStringCellValue());
break;
case 8:
System.out.println("setCompanyDetail="+cell.getStringCellValue());
c.setCompanyDetail( cell.getStringCellValue());
break;
}
c.setCreateMan(employee.getName());
c.setCreateDate(new Date());
}
customerInfoBiz.addCustomer(c);
}
} catch (Exception e) {
System.out.println("=========================");
//e.printStackTrace();
System.out.println("进入 ---解析excel 2003 版本文件--错误抛出");
try {
// 解析excel 2003 版本文件
is = new FileInputStream(excel);
HSSFWorkbook work = new HSSFWorkbook(is);
HSSFSheet sheet = work.getSheetAt(0);
if (sheet != null) {
System.out.println("解析excel 2003 版本文件");
int rows = sheet.getPhysicalNumberOfRows();
// 循环表的行,从第二行开始
for (int i = 1; i < rows; i++) {
c = new TCustomerInfo();
HSSFRow row = sheet.getRow(i);
if (row == null) {//判断是否为空
continue;
}
// 循环表格的列
System.out.println("row.getPhysicalNumberOfCells()=-========"+row.getPhysicalNumberOfCells());
for (short j = 0; j < row.getPhysicalNumberOfCells(); j++) {
HSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
if (cell.toString() == null || "".equals(cell.toString())) {
continue;
}
switch (j) {// 通过列数来判断对应插如的字段
case 0:
System.out.println("setCompanyName="+cell.getStringCellValue());
c.setCompanyName(cell.getStringCellValue());
break;
case 1:
System.out.println("setLinkName="+cell.getStringCellValue());
c.setLinkName(cell.getStringCellValue());
break;
case 2:
System.out.println("setTell="+cell.getStringCellValue());
c.setTell(cell.getStringCellValue());
break;
case 3:
System.out.println("setTelephone="+new BigDecimal(cell.getNumericCellValue()).toPlainString());
c.setTelephone(String.valueOf(new BigDecimal(cell.getNumericCellValue()).toPlainString()));
break;
case 4:
System.out.println("setPosition="+cell.getStringCellValue());
c.setPosition( cell.getStringCellValue());
break;
case 5:
System.out.println("setEmail="+cell.getStringCellValue());
c.setEmail( cell.getStringCellValue());
break;
case 6:
System.out.println(cell.getStringCellValue());
c.setCompanyType( cell.getStringCellValue());
break;
case 7:
System.out.println("setCustomerType="+cell.getStringCellValue());
c.setCustomerType( cell.getStringCellValue());
break;
case 8:
System.out.println("setCompanyDetail="+cell.getStringCellValue());
c.setCompanyDetail( cell.getStringCellValue());
break;
}
c.setCreateMan(employee.getName());
c.setCreateDate(new Date());
}
customerInfoBiz.addCustomer(c);
}
request.setAttribute("message", "导入成功(=^_^=)");
}
} catch (Exception e1) {
request.setAttribute("message", "导入失败,请注意导入格式!!");
e1.printStackTrace();
}
}
}
// 查询时对象中含有值对查询有误
if (customer != null) {
customer = null;
}
return customerList();
}
public String importExcle(){
System.out.println("------------");
TEmployee employee = (TEmployee) request.getSession().getAttribute("employee");
TCustomerInfo c=new TCustomerInfo();
// 声明数据流
InputStream is = null;
if(excel!=null){
try {
// 解析excel 2007 版本文件
is = new FileInputStream(excel);
XSSFWorkbook work = new XSSFWorkbook(is);
XSSFSheet sheet = work.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
// 循环表的行,从第二行开始
for (int i = 1; i < rows; i++) {
c = new TCustomerInfo();
XSSFRow row = sheet.getRow(i);
if (row == null) {//判断是否为空
continue;
}
// 读取该行的每一列
for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
XSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
if (cell.toString() == null || "".equals(cell.toString())) {
continue;
}
System.out.println(" 解析excel 2007 版本文件");
switch (j) {// 通过列数来判断对应插如的字段
case 0:
System.out.println("setCompanyName="+cell.getStringCellValue());
c.setCompanyName(cell.getStringCellValue());
break;
case 1:
System.out.println("setLinkName="+cell.getStringCellValue());
c.setLinkName(cell.getStringCellValue());
break;
case 2:
System.out.println("setTell="+cell.getStringCellValue());
c.setTell(cell.getStringCellValue());
break;
case 3:
System.out.println("setTelephone="+new BigDecimal(cell.getNumericCellValue()).toPlainString());
c.setTelephone(String.valueOf(new BigDecimal(cell.getNumericCellValue()).toPlainString()));
break;
case 4:
System.out.println("setPosition="+cell.getStringCellValue());
c.setPosition( cell.getStringCellValue());
break;
case 5:
System.out.println("setEmail="+cell.getStringCellValue());
c.setEmail( cell.getStringCellValue());
break;
case 6:
System.out.println(cell.getStringCellValue());
c.setCompanyType( cell.getStringCellValue());
break;
case 7:
System.out.println("setCustomerType="+cell.getStringCellValue());
c.setCustomerType( cell.getStringCellValue());
break;
case 8:
System.out.println("setCompanyDetail="+cell.getStringCellValue());
c.setCompanyDetail( cell.getStringCellValue());
break;
}
c.setCreateMan(employee.getName());
c.setCreateDate(new Date());
}
customerInfoBiz.addCustomer(c);
}
} catch (Exception e) {
System.out.println("=========================");
//e.printStackTrace();
System.out.println("进入 ---解析excel 2003 版本文件--错误抛出");
try {
// 解析excel 2003 版本文件
is = new FileInputStream(excel);
HSSFWorkbook work = new HSSFWorkbook(is);
HSSFSheet sheet = work.getSheetAt(0);
if (sheet != null) {
System.out.println("解析excel 2003 版本文件");
int rows = sheet.getPhysicalNumberOfRows();
// 循环表的行,从第二行开始
for (int i = 1; i < rows; i++) {
c = new TCustomerInfo();
HSSFRow row = sheet.getRow(i);
if (row == null) {//判断是否为空
continue;
}
// 循环表格的列
System.out.println("row.getPhysicalNumberOfCells()=-========"+row.getPhysicalNumberOfCells());
for (short j = 0; j < row.getPhysicalNumberOfCells(); j++) {
HSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
if (cell.toString() == null || "".equals(cell.toString())) {
continue;
}
switch (j) {// 通过列数来判断对应插如的字段
case 0:
System.out.println("setCompanyName="+cell.getStringCellValue());
c.setCompanyName(cell.getStringCellValue());
break;
case 1:
System.out.println("setLinkName="+cell.getStringCellValue());
c.setLinkName(cell.getStringCellValue());
break;
case 2:
System.out.println("setTell="+cell.getStringCellValue());
c.setTell(cell.getStringCellValue());
break;
case 3:
System.out.println("setTelephone="+new BigDecimal(cell.getNumericCellValue()).toPlainString());
c.setTelephone(String.valueOf(new BigDecimal(cell.getNumericCellValue()).toPlainString()));
break;
case 4:
System.out.println("setPosition="+cell.getStringCellValue());
c.setPosition( cell.getStringCellValue());
break;
case 5:
System.out.println("setEmail="+cell.getStringCellValue());
c.setEmail( cell.getStringCellValue());
break;
case 6:
System.out.println(cell.getStringCellValue());
c.setCompanyType( cell.getStringCellValue());
break;
case 7:
System.out.println("setCustomerType="+cell.getStringCellValue());
c.setCustomerType( cell.getStringCellValue());
break;
case 8:
System.out.println("setCompanyDetail="+cell.getStringCellValue());
c.setCompanyDetail( cell.getStringCellValue());
break;
}
c.setCreateMan(employee.getName());
c.setCreateDate(new Date());
}
customerInfoBiz.addCustomer(c);
}
request.setAttribute("message", "导入成功(=^_^=)");
}
} catch (Exception e1) {
request.setAttribute("message", "导入失败,请注意导入格式!!");
e1.printStackTrace();
}
}
}
// 查询时对象中含有值对查询有误
if (customer != null) {
customer = null;
}
return customerList();
}