package cn.superdesk.uniorder.controller.accounting.utils;

import cn.superdesk.uniorder.common.enums.pay.UnifiedOrderPayTypeEnum;
import cn.superdesk.uniorder.common.enums.accounting.customer.AccountingOrderCustomerAccountingStatusEnum;
import cn.superdesk.uniorder.dto.vo.accounting.score.customer.AccountingOrderScoreCustomerDetailVo;
import cn.superdesk.uniorder.dto.vo.accounting.unified.customer.statement.CustomerStatementOfAccountDetailVo;
import cn.superdesk.uniorder.dto.vo.invoice.customer.InvoiceApplyDetailDimCreditItemVo;
import cn.superdesk.uniorder.dto.vo.accounting.unified.customer.statement.CustomerStatementOfAccountDetailItemVo;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;

import java.text.SimpleDateFormat;

/**
 * @Description: 这个是产生对账单 发邮件时 要生成一个Excel
 * @Author: linjinyu
 * @CreateDate: 7/8/20 5:35 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 7/8/20 5:35 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class ExcelExportAccountingOrderDetailUtils {

	public static HSSFWorkbook unified(CustomerStatementOfAccountDetailVo customerStatementOfAccountDetailVo) throws Exception {

		SimpleDateFormat sdf      = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
		HSSFWorkbook     workbook = new HSSFWorkbook();

//		//获取文档信息,并配置
//		DocumentSummaryInformation dsi = workbook.getDocumentSummaryInformation();
//		//文档类别
//		dsi.setCategory("对账单信息");
//		//设置文档管理员
//		dsi.setManager("超级前台");
//		//设置组织机构
//		dsi.setCompany("前海超级前台");
//		//获取摘要信息并配置
//		SummaryInformation si = workbook.getSummaryInformation();
//		//设置文档主题
//		si.setSubject("对账单信息表");
//		//设置文档标题
//		si.setTitle("对账单");
//		//设置文档作者
//		si.setAuthor("超级前台");
//		//设置文档备注
//		si.setComments("备注信息暂无");
		//设置标题字体
		Font fontTitle = workbook.createFont();
		fontTitle.setFontHeightInPoints((short) 11); //字体大小
		//fontTitle.setColor();; //字体颜色
		fontTitle.setFontName("宋体"); //字体
		//fontTitle.setBold(true); //粗体显示
		//font.setItalic(true); //是否使用斜体
		//font.setStrikeout(true); //是否使用划线


		//设置标题单元格类型
		CellStyle cellStyleTitle = workbook.createCellStyle();
		cellStyleTitle.setFont(fontTitle);
		cellStyleTitle.setFillForegroundColor(IndexedColors.LIME.getIndex());
		//cellStyleTitle.setFillPattern(FillPatternType);
		cellStyleTitle.setAlignment(HorizontalAlignment.CENTER); //水平布局:居中
		cellStyleTitle.setVerticalAlignment(VerticalAlignment.CENTER);
		cellStyleTitle.setWrapText(true);//设置自动换行

		cellStyleTitle.setBorderBottom(BorderStyle.THIN); //下边框
		cellStyleTitle.setBorderLeft(BorderStyle.THIN);//左边框
		cellStyleTitle.setBorderTop(BorderStyle.THIN);//上边框
		cellStyleTitle.setBorderRight(BorderStyle.THIN);//右边框
		cellStyleTitle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
		cellStyleTitle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
		cellStyleTitle.setTopBorderColor(IndexedColors.BLACK.getIndex());
		cellStyleTitle.setRightBorderColor(IndexedColors.BLACK.getIndex());


		//生成一个表格,设置表格名称
		HSSFSheet sheet = workbook.createSheet("电子对账单");

		//设置表格列宽度为10个字节
		sheet.setDefaultColumnWidth(10);


		//创建合并单元格  ---begin
		CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		//在sheet里增加合并单元格
		CellRangeAddress region21 = new CellRangeAddress(1, 1, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region22 = new CellRangeAddress(1, 1, 3, 17);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region23 = new CellRangeAddress(1, 1, 18, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		CellRangeAddress region31 = new CellRangeAddress(2, 2, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region32 = new CellRangeAddress(2, 2, 3, 5);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region33 = new CellRangeAddress(2, 2, 6, 8);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region34 = new CellRangeAddress(2, 2, 9, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		CellRangeAddress region41 = new CellRangeAddress(3, 3, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region42 = new CellRangeAddress(3, 3, 3, 5);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region43 = new CellRangeAddress(3, 3, 6, 8);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region44 = new CellRangeAddress(3, 3, 9, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		CellRangeAddress region51 = new CellRangeAddress(4, 4, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region52 = new CellRangeAddress(4, 4, 3, 5);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region53 = new CellRangeAddress(4, 4, 6, 8);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region54 = new CellRangeAddress(4, 4, 9, 11);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region55 = new CellRangeAddress(4, 4, 12, 13);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region56 = new CellRangeAddress(4, 4, 14, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号


		sheet.addMergedRegion(region1);
		sheet.addMergedRegion(region21);
		sheet.addMergedRegion(region22);
		sheet.addMergedRegion(region23);
		sheet.addMergedRegion(region31);
		sheet.addMergedRegion(region32);
		sheet.addMergedRegion(region33);
		sheet.addMergedRegion(region34);
		sheet.addMergedRegion(region41);
		sheet.addMergedRegion(region42);
		sheet.addMergedRegion(region43);
		sheet.addMergedRegion(region44);
		sheet.addMergedRegion(region51);
		sheet.addMergedRegion(region52);
		sheet.addMergedRegion(region53);
		sheet.addMergedRegion(region54);
		sheet.addMergedRegion(region55);
		sheet.addMergedRegion(region56);

		//创建第一行表头
		HSSFRow row1 = sheet.createRow(0);
		//创建一个单元格
		HSSFCell cell = row1.createCell(0);
		//创建一个内容对象
		HSSFRichTextString text1 = new HSSFRichTextString("电子对账单");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		row1.setHeightInPoints(38);

		HSSFRow  row2   = sheet.createRow(1);
		HSSFCell cell20 = row2.createCell(0);
		text1 = new HSSFRichTextString("对账单编号");
		cell20.setCellValue(text1);
		cell20.setCellStyle(cellStyleTitle);

		HSSFCell cell21 = row2.createCell(3);
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getAccountingOrderSn());
		cell21.setCellValue(text1);
		cell21.setCellStyle(cellStyleTitle);

		HSSFCell cell22 = row2.createCell(18);
		text1 = new HSSFRichTextString(AccountingOrderCustomerAccountingStatusEnum.getDesc(customerStatementOfAccountDetailVo.getAccountingStatus()));
		cell22.setCellValue(text1);
		cell22.setCellStyle(cellStyleTitle);
		row2.setHeightInPoints(25);

		HSSFRow row3 = sheet.createRow(2);
		row3.setHeightInPoints(25);
		HSSFCell cell30 = row3.createCell(0);
		text1 = new HSSFRichTextString("企业名称");
		cell30.setCellValue(text1);
		cell30.setCellStyle(cellStyleTitle);
		HSSFCell cell31 = row3.createCell(3);
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getEnterpriseName());
		cell31.setCellValue(text1);
		cell31.setCellStyle(cellStyleTitle);
		HSSFCell cell32 = row3.createCell(6);
		text1 = new HSSFRichTextString("开票抬头:");
		cell32.setCellValue(text1);
		cell32.setCellStyle(cellStyleTitle);
		HSSFCell cell33 = row3.createCell(9);
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getInvoiceCompanyName());
		cell33.setCellValue(text1);
		cell33.setCellStyle(cellStyleTitle);

		HSSFRow row4 = sheet.createRow(3);
		row4.setHeightInPoints(25);
		cell = row4.createCell(0);
		text1 = new HSSFRichTextString("账单周期");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row4.createCell(3);
		SimpleDateFormat sdfs = new SimpleDateFormat("yyyy年MM月dd日");
		text1 = new HSSFRichTextString(sdfs.format(customerStatementOfAccountDetailVo.getStartTime()) + "-" + sdfs.format(customerStatementOfAccountDetailVo.getEndTime()));
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row4.createCell(6);
		text1 = new HSSFRichTextString("出账时间:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row4.createCell(9);
		text1 = new HSSFRichTextString(sdf.format(customerStatementOfAccountDetailVo.getCreateTime()));
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);

		HSSFRow row5 = sheet.createRow(4);
		row5.setHeightInPoints(25);
		cell = row5.createCell(0);
		text1 = new HSSFRichTextString("账单联系人");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(3);
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getPurchaseUserName());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(6);
		text1 = new HSSFRichTextString("账单联系人电话:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(9);
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getPurchasePhone());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(12);
		text1 = new HSSFRichTextString("地址");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(14);
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getPurchaseAddress());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);


		// 表格内容
		String[] cnames = {"序号",
//				"发票号",
				"订单编号",
//				"子订单编号",
				"下单时间", "商品名称", "单位", "数量", "单价(元)",
				"运费(元)", "小计(元)", "支付方式", "订单状态", "收货时间", "下单人",
//				"订单审核人",
				"收件人", "收件人电话",
				"收货地址", "订单类型", "备注"
		};

		HSSFRow rowtb = sheet.createRow(5);
		rowtb.setHeightInPoints(20);

		for (int i = 0; i < cnames.length; i++) {
			String item = cnames[i];
			cell = rowtb.createCell(i);
			text1 = new HSSFRichTextString(item);
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
		}

		int rowIndex = 6;

		for (int i = 0; i < customerStatementOfAccountDetailVo.getOrders().size(); i++) {
			HSSFRow                                rowitem = sheet.createRow(rowIndex);
			CustomerStatementOfAccountDetailItemVo order   = customerStatementOfAccountDetailVo.getOrders().get(i);

			// 序号
			cell = rowitem.createCell(0);
			text1 = new HSSFRichTextString((String.valueOf((i + 1))));
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

//			// 发票号
//			cell = rowitem.createCell(1);
//			text1 = new HSSFRichTextString(order.getInvNumber());
//			cell.setCellValue(text1);
//			cell.setCellStyle(cellStyleTitle);

			// 订单编号
			cell = rowitem.createCell(1);
			text1 = new HSSFRichTextString(order.getOrderSn());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

//			// 子订单编号
//			cell = rowitem.createCell(3);
//			text1 = new HSSFRichTextString(order.getOrderSn());
//			cell.setCellValue(text1);
//			cell.setCellStyle(cellStyleTitle);

			// 下单时间
			cell = rowitem.createCell(2);
			text1 = new HSSFRichTextString(sdf.format(order.getCreateTime()));
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 商品名称
			cell = rowitem.createCell(3);
			text1 = new HSSFRichTextString(order.getGoodsName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 单位
			cell = rowitem.createCell(4);
			text1 = new HSSFRichTextString("");
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 数量
			cell = rowitem.createCell(5);
			text1 = new HSSFRichTextString(order.getQuantity().toString());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 单价(元)
			cell = rowitem.createCell(6);
			text1 = new HSSFRichTextString(order.getPrice().toString());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 运费(元)
			cell = rowitem.createCell(7);
			text1 = new HSSFRichTextString(order.getTransportAmount() == null ? "0" : order.getTransportAmount().toString());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 小计(元)
			cell = rowitem.createCell(8);
			text1 = new HSSFRichTextString((order.getPrice().doubleValue() * order.getQuantity()) + "");
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 订单's 支付方式
			cell = rowitem.createCell(9);
			text1 = new HSSFRichTextString(UnifiedOrderPayTypeEnum.getDesc(order.getPayType()));
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 订单状态
			cell = rowitem.createCell(10);
			text1 = new HSSFRichTextString((order.getOrderStateName()));
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 收货时间
			cell = rowitem.createCell(11);
			text1 = new HSSFRichTextString(sdf.format(order.getCreateTime()));
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 下单人
			cell = rowitem.createCell(12);
			text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getPurchaseUserName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 订单审核人
//			cell = rowitem.createCell(15);
//			text1 = new HSSFRichTextString("");
//			cell.setCellValue(text1);
//			cell.setCellStyle(cellStyleTitle);

			// 收件人
			cell = rowitem.createCell(13);
			text1 = new HSSFRichTextString(order.getRecUserName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 收件人电话
			cell = rowitem.createCell(14);
			text1 = new HSSFRichTextString(order.getRecUserPhone());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 收货地址
			cell = rowitem.createCell(15);
			text1 = new HSSFRichTextString(order.getRecAddress());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 订单类型
			cell = rowitem.createCell(16);
			text1 = new HSSFRichTextString(order.getServiceName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// 备注
			cell = rowitem.createCell(17);
			text1 = new HSSFRichTextString(order.getRemarks());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			rowIndex++;
		}

		CellRangeAddress regionhj  = new CellRangeAddress(rowIndex, rowIndex, 0, 9);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regionhjq = new CellRangeAddress(rowIndex, rowIndex, 10, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		sheet.addMergedRegion(regionhj);
		sheet.addMergedRegion(regionhjq);
		HSSFRow newRow = sheet.createRow(rowIndex);
		newRow.setHeightInPoints(25);
		cell = newRow.createCell(0);
		text1 = new HSSFRichTextString("合计");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(10);
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getAccountingAmount().toString());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);

		rowIndex++;
		CellRangeAddress regiongy1 = new CellRangeAddress(rowIndex, rowIndex, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiongy2 = new CellRangeAddress(rowIndex, rowIndex, 3, 9);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiongy3 = new CellRangeAddress(rowIndex, rowIndex, 10, 12);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiongy4 = new CellRangeAddress(rowIndex, rowIndex, 13, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		sheet.addMergedRegion(regiongy1);
		sheet.addMergedRegion(regiongy2);
		sheet.addMergedRegion(regiongy3);
		sheet.addMergedRegion(regiongy4);
		newRow = sheet.createRow(rowIndex);
		newRow.setHeightInPoints(25);
		cell = newRow.createCell(0);
		text1 = new HSSFRichTextString("供货单位:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(3);

//		text1 = new HSSFRichTextString("深圳市超级前台信息技术有限公司");
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getBankInfo().getSupplyName());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(10);
		text1 = new HSSFRichTextString("收款方(单位):");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(13);
//		text1 = new HSSFRichTextString(sysInv.getInvName());
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getBankInfo().getCompanyName());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);


		/** ---------------------------------------------------------------------------- **/
		rowIndex++;
		CellRangeAddress regiondh1 = new CellRangeAddress(rowIndex, rowIndex, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondh2 = new CellRangeAddress(rowIndex, rowIndex, 3, 9);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondh3 = new CellRangeAddress(rowIndex, rowIndex, 10, 12);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondh4 = new CellRangeAddress(rowIndex, rowIndex, 13, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		sheet.addMergedRegion(regiondh1);
		sheet.addMergedRegion(regiondh2);
		sheet.addMergedRegion(regiondh3);
		sheet.addMergedRegion(regiondh4);
		newRow = sheet.createRow(rowIndex);
		newRow.setHeightInPoints(25);
		cell = newRow.createCell(0);
		text1 = new HSSFRichTextString("联系电话:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(3);

//		text1 = new HSSFRichTextString("400-8386-065");
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getBankInfo().getTel());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(10);
		text1 = new HSSFRichTextString("银行账号(公账):");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(13);
//		text1 = new HSSFRichTextString(sysInv.getBankNo());
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getBankInfo().getBankAccount());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);

		rowIndex++;
		CellRangeAddress regiondz1 = new CellRangeAddress(rowIndex, rowIndex, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondz2 = new CellRangeAddress(rowIndex, rowIndex, 3, 9);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondz3 = new CellRangeAddress(rowIndex, rowIndex, 10, 12);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondz4 = new CellRangeAddress(rowIndex, rowIndex, 13, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		sheet.addMergedRegion(regiondz1);
		sheet.addMergedRegion(regiondz2);
		sheet.addMergedRegion(regiondz3);
		sheet.addMergedRegion(regiondz4);
		newRow = sheet.createRow(rowIndex);
		newRow.setHeightInPoints(25);
		cell = newRow.createCell(0);
		text1 = new HSSFRichTextString("地址:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(3);

//		text1 = new HSSFRichTextString("深圳市 福田区 深南中路3024号 航空大厦32层7-11室");
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getBankInfo().getAddress());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(10);
		text1 = new HSSFRichTextString("银行开户行:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(13);
//		text1 = new HSSFRichTextString(sysInv.getBankName());
		text1 = new HSSFRichTextString(customerStatementOfAccountDetailVo.getBankInfo().getBankName());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);

		//加边框
		HSSFCellStyle cellStyle = workbook.createCellStyle();

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);

		int rowcount = 10 + customerStatementOfAccountDetailVo.getOrders().size();
		for (int i = 0; i < rowcount; i++) {
			HSSFRow r = sheet.getRow(i);
			if (r != null) {
				for (int j = 0; j < 21; j++) {
					HSSFCell c = r.getCell(j);
					if (c == null) {
						c = r.createCell(j);

					}
					c.setCellStyle(cellStyleTitle);
				}
			}

		}

		return workbook;
	}


	public static HSSFWorkbook score(AccountingOrderScoreCustomerDetailVo model) throws Exception {

		SimpleDateFormat sdf      = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
		HSSFWorkbook     workbook = new HSSFWorkbook();

//		//获取文档信息,并配置
//		DocumentSummaryInformation dsi = workbook.getDocumentSummaryInformation();
//		//文档类别
//		dsi.setCategory("对账单信息");
//		//设置文档管理员
//		dsi.setManager("超级前台");
//		//设置组织机构
//		dsi.setCompany("前海超级前台");
//		//获取摘要信息并配置
//		SummaryInformation si = workbook.getSummaryInformation();
//		//设置文档主题
//		si.setSubject("对账单信息表");
//		//设置文档标题
//		si.setTitle("对账单");
//		//设置文档作者
//		si.setAuthor("超级前台");
//		//设置文档备注
//		si.setComments("备注信息暂无");
		//设置标题字体
		Font fontTitle = workbook.createFont();
		fontTitle.setFontHeightInPoints((short) 11); //字体大小
		//fontTitle.setColor();; //字体颜色
		fontTitle.setFontName("宋体"); //字体
		//fontTitle.setBold(true); //粗体显示
		//font.setItalic(true); //是否使用斜体
		//font.setStrikeout(true); //是否使用划线


		//设置标题单元格类型
		CellStyle cellStyleTitle = workbook.createCellStyle();
		cellStyleTitle.setFont(fontTitle);
		cellStyleTitle.setFillForegroundColor(IndexedColors.LIME.getIndex());
		//cellStyleTitle.setFillPattern(FillPatternType);
		cellStyleTitle.setAlignment(HorizontalAlignment.CENTER); //水平布局:居中
		cellStyleTitle.setVerticalAlignment(VerticalAlignment.CENTER);
		cellStyleTitle.setWrapText(true);//设置自动换行

		cellStyleTitle.setBorderBottom(BorderStyle.THIN); //下边框
		cellStyleTitle.setBorderLeft(BorderStyle.THIN);//左边框
		cellStyleTitle.setBorderTop(BorderStyle.THIN);//上边框
		cellStyleTitle.setBorderRight(BorderStyle.THIN);//右边框
		cellStyleTitle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
		cellStyleTitle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
		cellStyleTitle.setTopBorderColor(IndexedColors.BLACK.getIndex());
		cellStyleTitle.setRightBorderColor(IndexedColors.BLACK.getIndex());


		//生成一个表格,设置表格名称
		HSSFSheet sheet = workbook.createSheet("电子对账单");

		//设置表格列宽度为10个字节
		sheet.setDefaultColumnWidth(10);


		//创建合并单元格  ---begin
		CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		//在sheet里增加合并单元格
		CellRangeAddress region21 = new CellRangeAddress(1, 1, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region22 = new CellRangeAddress(1, 1, 3, 17);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region23 = new CellRangeAddress(1, 1, 18, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		CellRangeAddress region31 = new CellRangeAddress(2, 2, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region32 = new CellRangeAddress(2, 2, 3, 5);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region33 = new CellRangeAddress(2, 2, 6, 8);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region34 = new CellRangeAddress(2, 2, 9, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		CellRangeAddress region41 = new CellRangeAddress(3, 3, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region42 = new CellRangeAddress(3, 3, 3, 5);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region43 = new CellRangeAddress(3, 3, 6, 8);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region44 = new CellRangeAddress(3, 3, 9, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		CellRangeAddress region51 = new CellRangeAddress(4, 4, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region52 = new CellRangeAddress(4, 4, 3, 5);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region53 = new CellRangeAddress(4, 4, 6, 8);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region54 = new CellRangeAddress(4, 4, 9, 11);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region55 = new CellRangeAddress(4, 4, 12, 13);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress region56 = new CellRangeAddress(4, 4, 14, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号


		sheet.addMergedRegion(region1);
		sheet.addMergedRegion(region21);
		sheet.addMergedRegion(region22);
		sheet.addMergedRegion(region23);
		sheet.addMergedRegion(region31);
		sheet.addMergedRegion(region32);
		sheet.addMergedRegion(region33);
		sheet.addMergedRegion(region34);
		sheet.addMergedRegion(region41);
		sheet.addMergedRegion(region42);
		sheet.addMergedRegion(region43);
		sheet.addMergedRegion(region44);
		sheet.addMergedRegion(region51);
		sheet.addMergedRegion(region52);
		sheet.addMergedRegion(region53);
		sheet.addMergedRegion(region54);
		sheet.addMergedRegion(region55);
		sheet.addMergedRegion(region56);

		//创建第一行表头
		HSSFRow row1 = sheet.createRow(0);
		//创建一个单元格
		HSSFCell cell = row1.createCell(0);
		//创建一个内容对象
		HSSFRichTextString text1 = new HSSFRichTextString("电子对账单");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		row1.setHeightInPoints(38);

		HSSFRow  row2   = sheet.createRow(1);
		HSSFCell cell20 = row2.createCell(0);
		text1 = new HSSFRichTextString("对账单编号");
		cell20.setCellValue(text1);
		cell20.setCellStyle(cellStyleTitle);

		HSSFCell cell21 = row2.createCell(3);
		text1 = new HSSFRichTextString(model.getAccounting().getAccountingOrderSn());
		cell21.setCellValue(text1);
		cell21.setCellStyle(cellStyleTitle);

		HSSFCell cell22 = row2.createCell(18);
		text1 = new HSSFRichTextString(AccountingOrderCustomerAccountingStatusEnum.getDesc(model.getAccounting().getAccountingStatus()));
		cell22.setCellValue(text1);
		cell22.setCellStyle(cellStyleTitle);
		row2.setHeightInPoints(25);

		HSSFRow row3 = sheet.createRow(2);
		row3.setHeightInPoints(25);
		HSSFCell cell30 = row3.createCell(0);
		text1 = new HSSFRichTextString("企业名称");
		cell30.setCellValue(text1);
		cell30.setCellStyle(cellStyleTitle);
		HSSFCell cell31 = row3.createCell(3);
		text1 = new HSSFRichTextString(model.getAccounting().getEnterpriseName());
		cell31.setCellValue(text1);
		cell31.setCellStyle(cellStyleTitle);
		HSSFCell cell32 = row3.createCell(6);
		text1 = new HSSFRichTextString("开票抬头:");
		cell32.setCellValue(text1);
		cell32.setCellStyle(cellStyleTitle);
		HSSFCell cell33 = row3.createCell(9);
		text1 = new HSSFRichTextString(model.getAccounting().getInvoiceCompanyName());
		cell33.setCellValue(text1);
		cell33.setCellStyle(cellStyleTitle);

		HSSFRow row4 = sheet.createRow(3);
		row4.setHeightInPoints(25);
		cell = row4.createCell(0);
		text1 = new HSSFRichTextString("账单周期");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row4.createCell(3);
		SimpleDateFormat sdfs = new SimpleDateFormat("yyyy年MM月dd日");
		text1 = new HSSFRichTextString(sdfs.format(model.getAccounting().getStartTime()) + "-" + sdfs.format(model.getAccounting().getEndTime()));
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row4.createCell(6);
		text1 = new HSSFRichTextString("出账时间:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row4.createCell(9);
		text1 = new HSSFRichTextString(sdf.format(model.getAccounting().getCreateTime()));
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);

		HSSFRow row5 = sheet.createRow(4);
		row5.setHeightInPoints(25);
		cell = row5.createCell(0);
		text1 = new HSSFRichTextString("账单联系人");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(3);
		text1 = new HSSFRichTextString(model.getAccounting().getPurchaseUserName());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(6);
		text1 = new HSSFRichTextString("账单联系人电话:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(9);
		text1 = new HSSFRichTextString(model.getAccounting().getPurchasePhone());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(12);
		text1 = new HSSFRichTextString("地址");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = row5.createCell(14);
		text1 = new HSSFRichTextString(model.getAccounting().getPurchaseAddress());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);


		// 表格内容
		String[] cnames = {"ID", "积分批次", "订单编号", "企业名称", "下单人姓名", "下单人手机号", "商品名称", "产品规格", "商品数量", "销售单价(元)", "销售总价(元)",
				"积分类型", "积分支付", "结算金额", "税率", "税务编码", "下单时间 ", "订单状态", "供贷方",
				"快递公司", "快递单号", "更新时间", "结算状态", "发票申请状态", "开票状态", "回款状态", "备注",
		};

		HSSFRow rowtb = sheet.createRow(5);
		rowtb.setHeightInPoints(20);
		for (int i = 0; i < cnames.length; i++) {
			String item = cnames[i];
			cell = rowtb.createCell(i);
			text1 = new HSSFRichTextString(item);
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
		}
		int rowIndex = 6;

		for (int i = 0; i < model.getCreditList().size(); i++) {

			HSSFRow rowitem = sheet.createRow(rowIndex);

			InvoiceApplyDetailDimCreditItemVo order = model.getCreditList().get(i);
			// ID
			cell = rowitem.createCell(0);
			text1 = new HSSFRichTextString(order.getUnifiedOrderCreditId().toString());// (String.valueOf((i + 1)))
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// 积分批次
			cell = rowitem.createCell(1);
			text1 = new HSSFRichTextString(order.getBatchs());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// 订单编号
			cell = rowitem.createCell(2);
			text1 = new HSSFRichTextString(order.getOrderSn());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// 企业名称
			cell = rowitem.createCell(3);
			text1 = new HSSFRichTextString(order.getPurchaseVirtName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			//  "下单人姓名",
			cell = rowitem.createCell(4);
			text1 = new HSSFRichTextString(order.getPurchaseUserName()); // sdf.format(order.getCreateTime())
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			//  "下单人手机号",
			cell = rowitem.createCell(5);
			text1 = new HSSFRichTextString(order.getPurchasePhone());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "商品名称",
			cell = rowitem.createCell(6);
			text1 = new HSSFRichTextString(order.getGoodsName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			//  "产品规格",
			cell = rowitem.createCell(7);
			text1 = new HSSFRichTextString(order.getCateNameLv3());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "商品数量",
			cell = rowitem.createCell(8);
			text1 = new HSSFRichTextString(order.getQuantity().toString());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "销售单价(元)",
			cell = rowitem.createCell(9);
			text1 = new HSSFRichTextString(order.getPrice().toString());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "销售总价(元)",
			cell = rowitem.createCell(10);
			text1 = new HSSFRichTextString(order.getTotalPrice().toString());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "积分类型",
			cell = rowitem.createCell(11);
			text1 = new HSSFRichTextString(order.getCreditName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "积分支付",
			cell = rowitem.createCell(12);
			text1 = new HSSFRichTextString(order.getBalance().toString());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "结算金额",
			cell = rowitem.createCell(13);
			text1 = new HSSFRichTextString(order.getBalance().toString());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "税率",
			cell = rowitem.createCell(14);
			text1 = new HSSFRichTextString(order.getTaxRate() != null ? order.getTaxRate().toString() : "");
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "税务编码",
			cell = rowitem.createCell(15);
			text1 = new HSSFRichTextString(order.getTaxCode());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			//  "下单时间 ",
			cell = rowitem.createCell(16);
			text1 = new HSSFRichTextString(sdf.format(order.getCreateTime()));
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			//  "订单状态",
			cell = rowitem.createCell(17);
			text1 = new HSSFRichTextString(order.getOrderStateName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "供贷方",
			cell = rowitem.createCell(18);
			text1 = new HSSFRichTextString(order.getSaleName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "快递公司",
			cell = rowitem.createCell(19);
			text1 = new HSSFRichTextString(order.getExpressCompany());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "快递单号",
			cell = rowitem.createCell(20);
			text1 = new HSSFRichTextString(order.getExpressSn());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "更新时间",
			cell = rowitem.createCell(21);
			text1 = new HSSFRichTextString(sdf.format(order.getUpdateTime()));
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);
			// "结算状态",
			cell = rowitem.createCell(22);
			text1 = new HSSFRichTextString(order.getAccountingStateCustomerName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// "发票申请状态",
			cell = rowitem.createCell(23);
			text1 = new HSSFRichTextString(order.getInvoiceApplyStatusName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// "开票状态",
			cell = rowitem.createCell(24);
			text1 = new HSSFRichTextString(order.getInvoiceMakeStatusName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// "回款状态",
			cell = rowitem.createCell(25);
			text1 = new HSSFRichTextString(order.getBackStatusName());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			// "备注",
			cell = rowitem.createCell(26);
			text1 = new HSSFRichTextString(order.getRemarks());
			cell.setCellValue(text1);
			cell.setCellStyle(cellStyleTitle);

			rowIndex++;
		}

		CellRangeAddress regionhj  = new CellRangeAddress(rowIndex, rowIndex, 0, 9);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regionhjq = new CellRangeAddress(rowIndex, rowIndex, 10, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		sheet.addMergedRegion(regionhj);
		sheet.addMergedRegion(regionhjq);
		HSSFRow newRow = sheet.createRow(rowIndex);
		newRow.setHeightInPoints(25);
		cell = newRow.createCell(0);
		text1 = new HSSFRichTextString("合计");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(10);
		text1 = new HSSFRichTextString(model.getAccounting().getAccountingAmount().toString());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);

		rowIndex++;
		CellRangeAddress regiongy1 = new CellRangeAddress(rowIndex, rowIndex, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiongy2 = new CellRangeAddress(rowIndex, rowIndex, 3, 9);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiongy3 = new CellRangeAddress(rowIndex, rowIndex, 10, 12);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiongy4 = new CellRangeAddress(rowIndex, rowIndex, 13, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		sheet.addMergedRegion(regiongy1);
		sheet.addMergedRegion(regiongy2);
		sheet.addMergedRegion(regiongy3);
		sheet.addMergedRegion(regiongy4);
		newRow = sheet.createRow(rowIndex);
		newRow.setHeightInPoints(25);
		cell = newRow.createCell(0);
		text1 = new HSSFRichTextString("供货单位:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(3);

		// TODO 写死
//		text1 = new HSSFRichTextString("深圳市超级前台信息技术有限公司");
		text1 = new HSSFRichTextString(model.getBankInfo() == null ? "收款方信息异常" : model.getBankInfo().getSupplyName());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(10);

		text1 = new HSSFRichTextString("收款方(单位):");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(13);
//		text1 = new HSSFRichTextString(sysInv.getInvName());
		text1 = new HSSFRichTextString(model.getBankInfo() == null ? "收款方信息异常" : model.getBankInfo().getCompanyName());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);


		/** ---------------------------------------------------------------------------- **/
		rowIndex++;
		CellRangeAddress regiondh1 = new CellRangeAddress(rowIndex, rowIndex, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondh2 = new CellRangeAddress(rowIndex, rowIndex, 3, 9);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondh3 = new CellRangeAddress(rowIndex, rowIndex, 10, 12);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondh4 = new CellRangeAddress(rowIndex, rowIndex, 13, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		sheet.addMergedRegion(regiondh1);
		sheet.addMergedRegion(regiondh2);
		sheet.addMergedRegion(regiondh3);
		sheet.addMergedRegion(regiondh4);
		newRow = sheet.createRow(rowIndex);
		newRow.setHeightInPoints(25);
		cell = newRow.createCell(0);
		text1 = new HSSFRichTextString("联系电话:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(3);
		// TODO 写死
//		text1 = new HSSFRichTextString("400-8386-065");
		text1 = new HSSFRichTextString(model.getBankInfo() == null ? "收款方信息异常" : model.getBankInfo().getTel());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(10);
		text1 = new HSSFRichTextString("银行账号(公账):");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);


		cell = newRow.createCell(13);
//		text1 = new HSSFRichTextString(sysInv.getBankNo());
		text1 = new HSSFRichTextString(model.getBankInfo() == null ? "收款方信息异常" : model.getBankInfo().getBankAccount());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);

		rowIndex++;
		CellRangeAddress regiondz1 = new CellRangeAddress(rowIndex, rowIndex, 0, 2);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondz2 = new CellRangeAddress(rowIndex, rowIndex, 3, 9);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondz3 = new CellRangeAddress(rowIndex, rowIndex, 10, 12);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
		CellRangeAddress regiondz4 = new CellRangeAddress(rowIndex, rowIndex, 13, 20);// 下标从0开始 起始行号,终止行号, 起始列号,终止列号

		sheet.addMergedRegion(regiondz1);
		sheet.addMergedRegion(regiondz2);
		sheet.addMergedRegion(regiondz3);
		sheet.addMergedRegion(regiondz4);
		newRow = sheet.createRow(rowIndex);
		newRow.setHeightInPoints(25);
		cell = newRow.createCell(0);
		text1 = new HSSFRichTextString("地址:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(3);
		// TODO 写死
//		text1 = new HSSFRichTextString("深圳市 福田区 深南中路3024号 航空大厦32层7-11室");
		text1 = new HSSFRichTextString(model.getBankInfo() == null ? "收款方信息异常" : model.getBankInfo().getAddress());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(10);
		text1 = new HSSFRichTextString("银行开户行:");
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);
		cell = newRow.createCell(13);

		text1 = new HSSFRichTextString(model.getBankInfo() == null ? "收款方信息异常" : model.getBankInfo().getBankName());
		cell.setCellValue(text1);
		cell.setCellStyle(cellStyleTitle);

		//加边框
		HSSFCellStyle cellStyle = workbook.createCellStyle();

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);

		int rowcount = 10 + model.getCreditList().size();
		for (int i = 0; i < rowcount; i++) {
			HSSFRow r = sheet.getRow(i);
			if (r != null) {
				for (int j = 0; j < 21; j++) {
					HSSFCell c = r.getCell(j);
					if (c == null) {
						c = r.createCell(j);

					}
					c.setCellStyle(cellStyleTitle);
				}
			}

		}

		return workbook;
	}


}
