1、update pkg path to com.lxyer
2、update bug for cell only 'NUMERIC' can't read 3、give up use poi's old api
This commit is contained in:
parent
9f92af761d
commit
a10f7e3680
@ -1,4 +1,4 @@
|
|||||||
package excel;
|
package com.lxyer.excel;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
@ -1,16 +1,16 @@
|
|||||||
package excel.poi;
|
package com.lxyer.excel.poi;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
|
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -142,7 +142,7 @@ public class ExcelKit {
|
|||||||
xlsName = new String(xlsName.getBytes("utf-8"),"iso-8859-1")+ ".xls";
|
xlsName = new String(xlsName.getBytes("utf-8"),"iso-8859-1")+ ".xls";
|
||||||
}
|
}
|
||||||
OutputStream os = response.getOutputStream();
|
OutputStream os = response.getOutputStream();
|
||||||
response.setContentType("application/vnd.ms-excel");
|
response.setContentType("application/vnd.ms-excel");
|
||||||
response.setHeader("Content-disposition", "attachment;filename="+xlsName);
|
response.setHeader("Content-disposition", "attachment;filename="+xlsName);
|
||||||
|
|
||||||
wb.write(os);
|
wb.write(os);
|
||||||
@ -331,10 +331,12 @@ public class ExcelKit {
|
|||||||
private static boolean isEmptyRow(Row row, int len){
|
private static boolean isEmptyRow(Row row, int len){
|
||||||
for (int i = 0; i< row.getLastCellNum() && i < len; i++) {
|
for (int i = 0; i< row.getLastCellNum() && i < len; i++) {
|
||||||
Cell cell = row.getCell(i);//列
|
Cell cell = row.getCell(i);//列
|
||||||
if (cell != null && cell.getCellType() != 0
|
if (cell != null){
|
||||||
&& cell.getStringCellValue() != null
|
if (cell.getCellTypeEnum() != CellType.NUMERIC && cell.getStringCellValue() != null && !cell.getStringCellValue().isEmpty()){
|
||||||
&& !cell.getStringCellValue().isEmpty()){
|
return false;
|
||||||
return false;
|
}else if (cell.getCellTypeEnum() == CellType.NUMERIC && cell.getNumericCellValue() != 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
@ -1,4 +1,4 @@
|
|||||||
package excel;
|
package com.lxyer.excel;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.redkale.net.http.HttpResponse;
|
import org.redkale.net.http.HttpResponse;
|
@ -1,4 +1,4 @@
|
|||||||
package excel;
|
package com.lxyer.excel;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user