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:
lxyer 2018-09-15 09:28:28 +08:00
parent 9f92af761d
commit a10f7e3680
4 changed files with 16 additions and 14 deletions

View File

@ -1,4 +1,4 @@
package excel;
package com.lxyer.excel;
import java.io.File;
import java.io.FileOutputStream;

View File

@ -1,16 +1,16 @@
package excel.poi;
package com.lxyer.excel.poi;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
import org.apache.poi.ss.usermodel.Cell;
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.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import javax.servlet.http.HttpServletRequest;
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.text.SimpleDateFormat;
import java.util.*;
@ -142,7 +142,7 @@ public class ExcelKit {
xlsName = new String(xlsName.getBytes("utf-8"),"iso-8859-1")+ ".xls";
}
OutputStream os = response.getOutputStream();
response.setContentType("application/vnd.ms-excel");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename="+xlsName);
wb.write(os);
@ -331,10 +331,12 @@ public class ExcelKit {
private static boolean isEmptyRow(Row row, int len){
for (int i = 0; i< row.getLastCellNum() && i < len; i++) {
Cell cell = row.getCell(i);//
if (cell != null && cell.getCellType() != 0
&& cell.getStringCellValue() != null
&& !cell.getStringCellValue().isEmpty()){
return false;
if (cell != null){
if (cell.getCellTypeEnum() != CellType.NUMERIC && cell.getStringCellValue() != null && !cell.getStringCellValue().isEmpty()){
return false;
}else if (cell.getCellTypeEnum() == CellType.NUMERIC && cell.getNumericCellValue() != 0){
return false;
}
}
}
return true;

View File

@ -1,4 +1,4 @@
package excel;
package com.lxyer.excel;
import org.junit.Test;
import org.redkale.net.http.HttpResponse;

View File

@ -1,4 +1,4 @@
package excel;
package com.lxyer.excel;
import java.util.Date;