1.导出功能(仅表头)
package nc.ui.yhlypx.yhlypxfkd.ace.action;
import java.awt.event.ActionEvent;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import nc.ui.pubapp.uif2app.model.BillManageModel;
import nc.ui.pubapp.uif2app.view.ShowUpableBillForm;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.ShowStatusBarMsgUtil;
import nc.ui.yhlypx.util.NullValueUtils;
import nc.ui.yhlypx.yhlypxfkd.ace.dialog.ExportFileDialog;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVOUtil;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.yhlypx.yhlypxfkd.AggYhlypxhtfkdVO;
import nc.vo.yhlypx.yhlypxfkd.YhlypxhtfkdVO;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExportActionHead extends NCAction {
private static final long serialVersionUID = -2288549251908687419L;
private BillManageModel model;
protected ShowUpableBillForm editor;
public ExportActionHead() {
setBtnName("导出表头");
setCode("exportAction");
}
@Override
public void doAction(ActionEvent arg0) throws Exception {
ExportFileDialog fileDlg = new ExportFileDialog();
if (fileDlg.show()) {
String filepath = fileDlg.getFilePath();
if (filepath == null) {
ShowStatusBarMsgUtil.showErrorMsg("提示", "请选择导出的文件!", getModel()
.getContext());
return;
}
try {
export(filepath);
} catch (Exception e) {
ExceptionUtils.wrappBusinessException("程序出错:" + e.getMessage());
}
}
ShowStatusBarMsgUtil.showStatusBarMsg("导出模板成功!", getModel()
.getContext());
}
public void export(String filepath) throws BusinessException {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
SXSSFWorkbook wb = new SXSSFWorkbook(xssfWorkbook, 100);
SXSSFSheet wbSheet = (SXSSFSheet) wb.createSheet(getExcelSheetName());
wbSheet.setDefaultColumnWidth(15);
CellStyle headStyle = getHeadStyle(wb);
CellStyle bodyStyle = getBodyStyle(wb);
CellStyle bodyStyleHjh = getBodyStyleHjh(wb);
SXSSFRow row = (SXSSFRow) wbSheet.createRow((int) 0);
SXSSFCell cellHead = null;
for (int i = 0; i < getExportFieldsName().length; i++) {
cellHead = (SXSSFCell) row.createCell(i);
cellHead.setCellValue(getExportFieldsName()[i]);
cellHead.setCellStyle(headStyle);
}
List<YhlypxhtfkdVO> list = new ArrayList<YhlypxhtfkdVO>();
Object[] selectedOperaDatas = getModel().getSelectedOperaDatas();
if(selectedOperaDatas == null){
throw new BusinessException(" 未选择导出数据! ");
}
for (int i = 0; i < selectedOperaDatas.length; i++) {
AggYhlypxhtfkdVO aggvo = (AggYhlypxhtfkdVO) selectedOperaDatas[i];
AggYhlypxhtfkdVO clone = (AggYhlypxhtfkdVO) aggvo.clone();
list.add(clone.getParentVO());
}
int nowRow = 1;
if (list != null && list.size() > 0) {
UFDouble fkjeyb = UFDouble.ZERO_DBL;
UFDouble fkjebb = UFDouble.ZERO_DBL;
YhlypxhtfkdVO[] array = list.toArray(new YhlypxhtfkdVO[list.size()]);
YhlypxhtfkdVO[] exeArray = execFormulaWithVOs(array);
for (YhlypxhtfkdVO vo : exeArray) {
SXSSFRow rows = (SXSSFRow) wbSheet.createRow(nowRow++);
SXSSFCell cellHeads = null;
String[] fieldsValue = new String[] {
NullValueUtils.getNullStringValue(vo.getDbilldate().toStdString().substring(0, 10)),
NullValueUtils.getNullStringValue(vo.getNqx()),
NullValueUtils.getNullStringValue(vo.getDenddate()),
NullValueUtils.getNullStringValue(vo.getPk_currtype()),
NullValueUtils.getNullStringValue(vo.getNorifkmny()),
NullValueUtils.getNullStringValue(vo.getCurrate()),
NullValueUtils.getNullStringValue(vo.getNfkmny()),
NullValueUtils.getNullStringValue(vo.getReratedays()),
NullValueUtils.getNullStringValue(vo.getJxzq()),
NullValueUtils.getNullStringValue(vo.getQxunit()),
NullValueUtils.getNullStringValue(vo.getHth()),
NullValueUtils.getNullStringValue(vo.getSumnum())
};
if(!fieldsValue[2].equals("")){
fieldsValue[2] = fieldsValue[2].substring(0, 10);
}
for (int j = 0; j < fieldsValue.length; j++) {
cellHeads = (SXSSFCell) rows.createCell(j);
cellHeads.setCellValue(fieldsValue[j]);
cellHeads.setCellStyle(bodyStyle);
if(vo.getAttributeValue(getExportFieldsCode()[j]) instanceof UFDouble && j==4){
fkjeyb = fkjeyb.add(NullValueUtils.getNullUFdoubleValue(vo.getAttributeValue(getExportFieldsCode()[j])));
}else if(vo.getAttributeValue(getExportFieldsCode()[j]) instanceof UFDouble && j==6){
fkjebb = fkjebb.add(NullValueUtils.getNullUFdoubleValue(vo.getAttributeValue(getExportFieldsCode()[j])));
}
}
wbSheet.createRow(nowRow);
for(int i=0; i<fieldsValue.length; i++){
wbSheet.getRow(nowRow).createCell(i);
if(i == 0){
wbSheet.getRow(nowRow).getCell(i).setCellStyle(bodyStyle);
wbSheet.getRow(nowRow).getCell(i).setCellValue("合计行");
}else if(i == 4){
wbSheet.getRow(nowRow).getCell(i).setCellValue(getStringByUFDouble(fkjeyb));
wbSheet.getRow(nowRow).getCell(i).setCellStyle(bodyStyleHjh);
}else if(i == 6){
wbSheet.getRow(nowRow).getCell(i).setCellValue(getStringByUFDouble(fkjebb));
wbSheet.getRow(nowRow).getCell(i).setCellStyle(bodyStyleHjh);
}else{
wbSheet.getRow(nowRow).getCell(i).setCellStyle(bodyStyle);
}
}
}
}
try {
FileOutputStream fout = new FileOutputStream(filepath
+ "\\放款单(仅表头)"
+ new UFDate().toStdString().substring(0, 10) + ".xlsx");
wb.write(fout);
fout.close();
} catch (Exception e) {
throw new BusinessException("生成excel出错:" + e.getMessage());
}
}
private YhlypxhtfkdVO[] execFormulaWithVOs(YhlypxhtfkdVO[] hvos) {
YhlypxhtfkdVO[] clonevos = hvos.clone();
SuperVOUtil.execFormulaWithVOs(clonevos, new String[] {
"pk_currtype->getColValue(bd_currtype,name,pk_currtype,pk_currtype)",
"hth->getColValue(yhly_yhlypxdkht,vbillno,pk_dkht,hth)"
});
return clonevos;
}
private String[] getExportFieldsName() {
return new String[] { "单据日期", "期限", "最后一次还款日期", "币种", "放款金额(原币)",
"本币汇率", "放款金额(本币)", "利率天数", "结息周期", "期限单位",
"合同号", "累计放款单数量" };
}
private String[] getExportFieldsCode() {
return new String[] { "dbilldate", "nqx", "denddate", "pk_currtype", "norifkmny",
"currate", "nfkmny", "reratedays", "jxzq", "qxunit", "hth", "sumnum" };
}
private String getExcelSheetName() {
String date = new UFDate().toString().substring(0, 10);
return "放款单" + date;
}
public BillManageModel getModel() {
return model;
}
public void setModel(BillManageModel model) {
this.model = model;
this.model.addAppEventListener(this);
}
public ShowUpableBillForm getEditor() {
return editor;
}
public void setEditor(ShowUpableBillForm editor) {
this.editor = editor;
}
public CellStyle getHeadStyle(SXSSFWorkbook wb) {
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setWrapText(false);
XSSFFont font = (XSSFFont) wb.createFont();
font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
font.setFontName("宋体");
font.setFontHeight(14);
cellStyle.setFont(font);
cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);
return cellStyle;
}
public CellStyle getBodyStyle(SXSSFWorkbook wb) {
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setWrapText(false);
XSSFFont font = (XSSFFont) wb.createFont();
font.setFontName("宋体");
font.setFontHeight(12);
cellStyle.setFont(font);
cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);
return cellStyle;
}
public CellStyle getBodyStyleHjh (SXSSFWorkbook wb){
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.ORANGE.index);
cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setWrapText(false);
XSSFFont font = (XSSFFont) wb.createFont();
font.setFontName("宋体");
font.setFontHeight(12);
cellStyle.setFont(font);
cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);
return cellStyle;
}
public static UFDouble getUFDoubleNullValue(Object obj) {
return obj == null?UFDouble.ZERO_DBL:new UFDouble(obj.toString());
}
private Double getStringByUFDouble(UFDouble value){
if(value==null){
value = UFDouble.ZERO_DBL;
}else{
value = new UFDouble(value.toString());
}
return value.toDouble();
}
}
2.导出功能(表头加表体)
package nc.ui.yhlypx.yhlypxfkd.ace.action;
import java.awt.event.ActionEvent;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import nc.ui.pubapp.uif2app.model.BillManageModel;
import nc.ui.pubapp.uif2app.view.ShowUpableBillForm;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.ShowStatusBarMsgUtil;
import nc.ui.yhlypx.util.NullValueUtils;
import nc.ui.yhlypx.yhlypxfkd.ace.dialog.ExportFileDialog;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVOUtil;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.yhlypx.yhlypxfkd.AggYhlypxhtfkdVO;
import nc.vo.yhlypx.yhlypxfkd.YhlypxhtfkBVO;
import nc.vo.yhlypx.yhlypxfkd.YhlypxhtfkdVO;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExportActionHeadAndBody extends NCAction {
private static final long serialVersionUID = -2288549251908687419L;
private BillManageModel model;
protected ShowUpableBillForm editor;
public ExportActionHeadAndBody() {
setBtnName("导出表头和表体");
setCode("exportAction");
}
@Override
public void doAction(ActionEvent arg0) throws Exception {
ExportFileDialog fileDlg = new ExportFileDialog();
if (fileDlg.show()) {
String filepath = fileDlg.getFilePath();
if (filepath == null) {
ShowStatusBarMsgUtil.showErrorMsg("提示", "请选择导出的文件!", getModel()
.getContext());
return;
}
try {
export(filepath);
} catch (Exception e) {
ExceptionUtils.wrappBusinessException("程序出错:" + e.getMessage());
}
}
ShowStatusBarMsgUtil.showStatusBarMsg("导出模板成功!", getModel()
.getContext());
}
public void export(String filepath) throws BusinessException {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
List<YhlypxhtfkdVO> headvolist = new ArrayList<YhlypxhtfkdVO>();
List<YhlypxhtfkBVO> bodyvolist = new ArrayList<YhlypxhtfkBVO>();
Object[] selectedOperaDatas = getModel().getSelectedOperaDatas();
if(selectedOperaDatas == null){
throw new BusinessException(" 未选择导出数据! ");
}
for (int i = 0; i < selectedOperaDatas.length; i++) {
AggYhlypxhtfkdVO aggvo = (AggYhlypxhtfkdVO) selectedOperaDatas[i];
AggYhlypxhtfkdVO clone = (AggYhlypxhtfkdVO) aggvo.clone();
YhlypxhtfkBVO[] bodyvos = (YhlypxhtfkBVO[]) clone.getChildrenVO();
headvolist.add((YhlypxhtfkdVO) clone.getParentVO());
for (int j = 0; j < bodyvos.length; j++) {
bodyvolist.add(bodyvos[j]);
}
}
if(headvolist.size() > 0){
exportwzxqsqd(xssfWorkbook,headvolist);
exportwzxqsqdbvo(xssfWorkbook,bodyvolist);
}
try {
FileOutputStream fout = new FileOutputStream(filepath
+ "\\放款单(表头加表体)"
+ new UFDate().toStdString().substring(0, 10) + ".xlsx");
xssfWorkbook.write(fout);
fout.close();
} catch (Exception e) {
throw new BusinessException("生成excel出错:" + e.getMessage());
}
}
private void exportwzxqsqd(XSSFWorkbook xb, List<YhlypxhtfkdVO> headvolist) {
YhlypxhtfkdVO[] hvoArray = headvolist.toArray(new YhlypxhtfkdVO[headvolist.size()]);
YhlypxhtfkdVO[] exeHvoArray = execFormulaWithHVOs(hvoArray);
xb.createSheet(getExcelSheetHeadName());
XSSFSheet xssfSheet = xb.getSheetAt(0);
xssfSheet.setDefaultColumnWidth(15);
CellStyle headStyle = getHeadStyle(xb);
CellStyle bodyStyle = getBodyStyle(xb);
xssfSheet.setRowBreak(headvolist.size());
XSSFRow row = (XSSFRow) xssfSheet.createRow((int) 0);
XSSFCell cellHead = null;
for (int i = 0; i < getExportFieldsHeadName().length; i++) {
cellHead = (XSSFCell) row.createCell(i);
cellHead.setCellValue(getExportFieldsHeadName()[i]);
cellHead.setCellStyle(headStyle);
}
int nowRow = 1;
UFDouble fkjeyb = UFDouble.ZERO_DBL;
UFDouble fkjebb = UFDouble.ZERO_DBL;
for (int i = 0; i < exeHvoArray.length; i++) {
YhlypxhtfkdVO hvo = (YhlypxhtfkdVO) exeHvoArray[i];
XSSFRow rows = (XSSFRow) xssfSheet.createRow(nowRow++);
XSSFCell cellHeads = null;
String[] fieldsValue = new String[]{
NullValueUtils.getNullStringValue(hvo.getDbilldate().toStdString().substring(0, 10)),
NullValueUtils.getNullStringValue(hvo.getNqx()),
NullValueUtils.getNullStringValue(hvo.getDenddate()),
NullValueUtils.getNullStringValue(hvo.getPk_currtype()),
NullValueUtils.getNullStringValue(hvo.getNorifkmny()),
NullValueUtils.getNullStringValue(hvo.getCurrate()),
NullValueUtils.getNullStringValue(hvo.getNfkmny()),
NullValueUtils.getNullStringValue(hvo.getReratedays()),
NullValueUtils.getNullStringValue(hvo.getJxzq()),
NullValueUtils.getNullStringValue(hvo.getQxunit()),
NullValueUtils.getNullStringValue(hvo.getHth()),
NullValueUtils.getNullStringValue(hvo.getSumnum())
};
if(!fieldsValue[2].equals("")){
fieldsValue[2] = fieldsValue[2].substring(0, 10);
}
for (int j = 0; j < fieldsValue.length; j++) {
cellHeads = (XSSFCell) rows.createCell(j);
cellHeads.setCellValue(fieldsValue[j]);
cellHeads.setCellStyle(bodyStyle);
if(hvo.getAttributeValue(getExportFieldsCode()[j]) instanceof UFDouble && j==4){
fkjeyb = fkjeyb.add(NullValueUtils.getNullUFdoubleValue(hvo.getAttributeValue(getExportFieldsCode()[j])));
}else if(hvo.getAttributeValue(getExportFieldsCode()[j]) instanceof UFDouble && j==6){
fkjebb = fkjebb.add(NullValueUtils.getNullUFdoubleValue(hvo.getAttributeValue(getExportFieldsCode()[j])));
}
}
xssfSheet.createRow(nowRow);
for(int j=0; j<fieldsValue.length; j++){
xssfSheet.getRow(nowRow).createCell(j);
xssfSheet.getRow(nowRow).getCell(j).setCellStyle(bodyStyle);
if(j == 0){
xssfSheet.getRow(nowRow).getCell(j).setCellValue("合计行");
}else if(j == 4){
xssfSheet.getRow(nowRow).getCell(j).setCellValue(getStringByUFDouble(fkjeyb));
}else if(j == 6){
xssfSheet.getRow(nowRow).getCell(j).setCellValue(getStringByUFDouble(fkjebb));
}
}
}
}
private void exportwzxqsqdbvo(XSSFWorkbook xb, List<YhlypxhtfkBVO> bodyvolist) {
YhlypxhtfkBVO[] bvoArray = bodyvolist.toArray(new YhlypxhtfkBVO[bodyvolist.size()]);
YhlypxhtfkBVO[] exeBvoArray = execFormulaWithBVOs(bvoArray);
xb.createSheet(getExcelSheetBodyName());
XSSFSheet xssfSheet = xb.getSheetAt(1);
xssfSheet.setDefaultColumnWidth(15);
CellStyle headStyle = getHeadStyle(xb);
CellStyle bodyStyle = getBodyStyle(xb);
XSSFRow row = (XSSFRow) xssfSheet.createRow((int) 0);
XSSFCell cellHead = null;
for (int i = 0; i < getExportFieldsBodyName().length; i++) {
cellHead = (XSSFCell) row.createCell(i);
cellHead.setCellValue(getExportFieldsBodyName()[i]);
cellHead.setCellStyle(headStyle);
}
int nowRow = 1;
int rowno = 0;
for (int i = 0; i < exeBvoArray.length; i++) {
YhlypxhtfkBVO bvo = exeBvoArray[i];
XSSFRow rows = (XSSFRow) xssfSheet.createRow(nowRow++);
XSSFCell cellHeads = null;
String[] fieldsValue = new String[]{
++rowno+"",
NullValueUtils.getNullStringValue(bvo.getHkno()),
NullValueUtils.getNullStringValue(getUFDate(bvo.getDstartdate())),
NullValueUtils.getNullStringValue(getUFDate(bvo.getDhkdate())),
NullValueUtils.getNullStringValue(bvo.getNprice()),
NullValueUtils.getNullStringValue(bvo.getNnum()),
NullValueUtils.getNullStringValue(bvo.getNmny()==null ? 0.00 : bvo.getNmny().setScale(2, UFDouble.ROUND_HALF_UP)),
NullValueUtils.getNullStringValue(bvo.getSumlxd())
};
for (int j = 0; j < fieldsValue.length; j++) {
cellHeads = (XSSFCell) rows.createCell(j);
cellHeads.setCellValue(fieldsValue[j]);
cellHeads.setCellStyle(bodyStyle);
}
}
}
private YhlypxhtfkdVO[] execFormulaWithHVOs(YhlypxhtfkdVO[] hvos) {
YhlypxhtfkdVO[] clonevos = hvos.clone();
SuperVOUtil.execFormulaWithVOs(clonevos, new String[] {
"pk_currtype->getColValue(bd_currtype,name,pk_currtype,pk_currtype)",
"hth->getColValue(yhly_yhlypxdkht,vbillno,pk_dkht,hth)"
});
return clonevos;
}
private YhlypxhtfkBVO[] execFormulaWithBVOs(YhlypxhtfkBVO[] bvos) {
YhlypxhtfkBVO[] clonevos = bvos.clone();
SuperVOUtil.execFormulaWithVOs(clonevos, new String[] {
});
return clonevos;
}
private String[] getExportFieldsHeadName() {
return new String[] { "单据日期", "期限", "最后一次还款日期", "币种", "放款金额(原币)",
"本币汇率", "放款金额(本币)", "利率天数", "结息周期", "期限单位",
"合同号", "累计放款单数量" };
}
private String[] getExportFieldsCode() {
return new String[] { "dbilldate", "nqx", "denddate", "pk_currtype", "norifkmny",
"currate", "nfkmny", "reratedays", "jxzq", "qxunit", "hth", "sumnum" };
}
private String[] getExportFieldsBodyName() {
return new String[] { "行号", "还款编号", "开始计息日期", "还款日期", "单价",
"数量", "金额", "累计利息单数量" };
}
private String getExcelSheetHeadName() {
String date = new UFDate().toString().substring(0, 10);
return "放款单表头" + date;
}
private String getExcelSheetBodyName() {
String date = new UFDate().toString().substring(0, 10);
return "放款单表体" + date;
}
public BillManageModel getModel() {
return model;
}
public void setModel(BillManageModel model) {
this.model = model;
this.model.addAppEventListener(this);
}
public ShowUpableBillForm getEditor() {
return editor;
}
public void setEditor(ShowUpableBillForm editor) {
this.editor = editor;
}
private String getUFDate(Object value) {
if(value == null){
return "";
}else{
return value.toString().substring(0, 10);
}
}
public CellStyle getHeadStyle(XSSFWorkbook xb) {
CellStyle cellStyle = xb.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setWrapText(false);
XSSFFont font = (XSSFFont) xb.createFont();
font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
font.setFontName("宋体");
font.setFontHeight(14);
cellStyle.setFont(font);
cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);
return cellStyle;
}
public CellStyle getBodyStyle(XSSFWorkbook xb) {
CellStyle cellStyle = xb.createCellStyle();
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setWrapText(false);
XSSFFont font = (XSSFFont) xb.createFont();
font.setFontName("宋体");
font.setFontHeight(12);
cellStyle.setFont(font);
cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);
return cellStyle;
}
private Double getStringByUFDouble(UFDouble value){
if(value==null){
value = UFDouble.ZERO_DBL;
}else{
value = new UFDouble(value.toString());
}
return value.toDouble();
}
}