@@ -46,10 +46,6 @@ public class ExcelExportEntity extends ExcelBaseEntity { | |||||
* 合并依赖 | * 合并依赖 | ||||
*/ | */ | ||||
private int[] mergeRely; | private int[] mergeRely; | ||||
/** | |||||
* cell 函数 | |||||
*/ | |||||
private String cellFormula; | |||||
/** | /** | ||||
* 后缀 | * 后缀 | ||||
*/ | */ | ||||
@@ -80,10 +76,6 @@ public class ExcelExportEntity extends ExcelBaseEntity { | |||||
this.key = key; | this.key = key; | ||||
} | } | ||||
public String getCellFormula() { | |||||
return cellFormula; | |||||
} | |||||
public int getExportImageType() { | public int getExportImageType() { | ||||
return exportImageType; | return exportImageType; | ||||
} | } | ||||
@@ -124,10 +116,6 @@ public class ExcelExportEntity extends ExcelBaseEntity { | |||||
return isWrap; | return isWrap; | ||||
} | } | ||||
public void setCellFormula(String cellFormula) { | |||||
this.cellFormula = cellFormula; | |||||
} | |||||
public void setExportImageType(int exportImageType) { | public void setExportImageType(int exportImageType) { | ||||
this.exportImageType = exportImageType; | this.exportImageType = exportImageType; | ||||
} | } | ||||
@@ -142,7 +142,7 @@ public class ExcelExportServer extends ExcelExportBase { | |||||
mergeCells(sheet, excelParams, titleHeight); | mergeCells(sheet, excelParams, titleHeight); | ||||
if (entity.getFreezeCol() != 0) { | if (entity.getFreezeCol() != 0) { | ||||
sheet.createFreezePane(1, 0, entity.getFreezeCol(), 0); | |||||
sheet.createFreezePane(entity.getFreezeCol(), 0, entity.getFreezeCol(), 0); | |||||
} | } | ||||
its = dataSet.iterator(); | its = dataSet.iterator(); | ||||
@@ -215,6 +215,10 @@ public class ExcelExportServer extends ExcelExportBase { | |||||
if (index >= MAX_NUM) | if (index >= MAX_NUM) | ||||
break; | break; | ||||
} | } | ||||
if (entity.getFreezeCol() != 0) { | |||||
sheet.createFreezePane(entity.getFreezeCol(), 0, entity.getFreezeCol(), 0); | |||||
} | |||||
mergeCells(sheet, excelParams, titleHeight); | mergeCells(sheet, excelParams, titleHeight); | ||||
its = dataSet.iterator(); | its = dataSet.iterator(); | ||||
@@ -0,0 +1,40 @@ | |||||
package org.jeecgframework.poi.test.excel.styler; | |||||
import org.apache.poi.ss.usermodel.BuiltinFormats; | |||||
import org.apache.poi.ss.usermodel.CellStyle; | |||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity; | |||||
import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerDefaultImpl; | |||||
/** | |||||
* Excel 自定义styler 的例子 | |||||
* @author JueYue | |||||
* @date 2015年3月29日 下午9:04:41 | |||||
*/ | |||||
public class ExcelExportStatisticStyler extends ExcelExportStylerDefaultImpl { | |||||
private CellStyle numberCellStyle; | |||||
public ExcelExportStatisticStyler(Workbook workbook) { | |||||
super(workbook); | |||||
createNumberCellStyler(); | |||||
} | |||||
private void createNumberCellStyler() { | |||||
numberCellStyle = workbook.createCellStyle(); | |||||
numberCellStyle.setAlignment(CellStyle.ALIGN_CENTER); | |||||
numberCellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); | |||||
numberCellStyle.setDataFormat((short) BuiltinFormats.getBuiltinFormat("0")); | |||||
numberCellStyle.setWrapText(true); | |||||
} | |||||
@Override | |||||
public CellStyle getStyles(boolean noneStyler, ExcelExportEntity entity) { | |||||
if (entity != null | |||||
&& (entity.getName().contains("int") || entity.getName().contains("long"))) { | |||||
return numberCellStyle; | |||||
} | |||||
return super.getStyles(noneStyler, entity); | |||||
} | |||||
} |
@@ -8,7 +8,7 @@ import java.util.HashMap; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||||
//import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||||
import org.apache.poi.ss.usermodel.Workbook; | import org.apache.poi.ss.usermodel.Workbook; | ||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | import org.jeecgframework.poi.excel.ExcelExportUtil; | ||||
import org.jeecgframework.poi.excel.entity.ExportParams; | import org.jeecgframework.poi.excel.entity.ExportParams; | ||||
@@ -66,7 +66,8 @@ public class ExcelExportForMap { | |||||
} | } | ||||
list.add(map); | list.add(map); | ||||
} | } | ||||
ExportParams params = new ExportParams("测试", "测试", ExcelType.HSSF); | |||||
ExportParams params = new ExportParams("测试", "测试", ExcelType.XSSF); | |||||
params.setFreezeCol(5); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(params, entity, list); | Workbook workbook = ExcelExportUtil.exportExcel(params, entity, list); | ||||
FileOutputStream fos = new FileOutputStream("d:/tt.xlsx"); | FileOutputStream fos = new FileOutputStream("d:/tt.xlsx"); | ||||
workbook.write(fos); | workbook.write(fos); | ||||
@@ -14,6 +14,7 @@ import org.jeecgframework.poi.excel.entity.enmus.ExcelStyleType; | |||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType; | import org.jeecgframework.poi.excel.entity.enmus.ExcelType; | ||||
import org.jeecgframework.poi.excel.entity.vo.PoiBaseConstants; | import org.jeecgframework.poi.excel.entity.vo.PoiBaseConstants; | ||||
import org.jeecgframework.poi.test.entity.statistics.StatisticEntity; | import org.jeecgframework.poi.test.entity.statistics.StatisticEntity; | ||||
import org.jeecgframework.poi.test.excel.styler.ExcelExportStatisticStyler; | |||||
import org.junit.Test; | import org.junit.Test; | ||||
public class ExcelExportStatisticTest { | public class ExcelExportStatisticTest { | ||||
@@ -32,7 +33,8 @@ public class ExcelExportStatisticTest { | |||||
list.add(client); | list.add(client); | ||||
} | } | ||||
Date start = new Date(); | Date start = new Date(); | ||||
ExportParams params = new ExportParams("2412312", "测试",ExcelType.XSSF); | |||||
ExportParams params = new ExportParams("2412312", "测试", ExcelType.XSSF); | |||||
params.setStyle(ExcelExportStatisticStyler.class); | |||||
Workbook workbook = ExcelExportUtil.exportExcel(params, StatisticEntity.class, list); | Workbook workbook = ExcelExportUtil.exportExcel(params, StatisticEntity.class, list); | ||||
System.out.println(new Date().getTime() - start.getTime()); | System.out.println(new Date().getTime() - start.getTime()); | ||||
File savefile = new File("d:/"); | File savefile = new File("d:/"); | ||||