Commit aa917bd1 authored by Quxl's avatar Quxl

x

parent 7b1650c8
Pipeline #88 failed with stages
......@@ -15,7 +15,9 @@ import java.util.List;
import java.util.Map;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
......@@ -80,6 +82,8 @@ public class ExcelUtil {
public static void excel(OutputStream os, Object[][] objs, Integer[] widths) {
try {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFCellStyle bodyStyle = wb.createCellStyle();
bodyStyle.setWrapText(true);
HSSFSheet sheet = wb.createSheet("sheet1");
if(widths != null) {
for(int i = 0; i < widths.length; i++) {
......@@ -88,6 +92,7 @@ public class ExcelUtil {
}
}
}
for (int row_index = 0; row_index < objs.length; row_index++) {
HSSFRow row = sheet.createRow(row_index);
for(int cell_index = 0; (row_index < objs.length && cell_index < objs[row_index].length); cell_index++) {
......@@ -98,7 +103,8 @@ public class ExcelUtil {
if(type == Date.class) {
cell.setCellValue(DateUtil.format((Date)obj));
} else {
cell.setCellValue(String.valueOf(obj));
cell.setCellStyle(bodyStyle);
cell.setCellValue(new HSSFRichTextString(String.valueOf(obj)));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment