package com.ruoyi.indica.service.impl;

import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.springframework.stereotype.Service;

import com.ruoyi.indica.domain.CIndicationInfo;
import com.ruoyi.indica.service.ICIndicationInfoExcel;
import com.ruoyi.indica.vo.CIndicationInfoDTO;
import com.ruoyi.indica.vo.CIndicationInfoVO;
import com.ruoyi.report.service.impl.AbstractExcelExp;
import com.ruoyi.trade.vo.TrademarkDTO;
import com.ruoyi.trade.vo.TrademarkVO;

import io.swagger.v3.oas.annotations.servers.Server;

@Service
public class CIndicationInfoExcelImpl extends AbstractExcelExp implements ICIndicationInfoExcel {

	@Override
	public void exportReportMark(OutputStream out, CIndicationInfo req, CIndicationInfoDTO dto) {

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "地理标志证明商标注册情况";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);

			int column = 0;
			int row = 0;
			Row titleRow0 = sheet.createRow(row);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(column);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 0;
			if (dto.getYears() != null && dto.getYears().size() > 0) {
				int size = dto.getYears().size();
				titleSize = titleSize + size;
			}

			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(
					new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(), column, titleSize));

			row++;
			Row titleRow1 = sheet.createRow(row);
			titleRow1.setHeight(headHeight);
			String val = "地区";
			XSSFCellStyle header = styles.get("header");
			createCell(titleRow1, column, val, header);
			CellRangeAddress titleRowRange = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum() + 1, 0,
					0);
			sheet.addMergedRegion(titleRowRange);

			val = "统计时期";
			if (StringUtils.isNotBlank(req.getCountTimeStr())) {
				val = req.getCountTimeStr();
			}
			column++;
			createCell(titleRow1, column, val, header);
			CellRangeAddress titleRange1 = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum(), column,
					titleSize);
			sheet.addMergedRegion(titleRange1);

			row++;
			Row titleRow2 = sheet.createRow(row);
			titleRow2.setHeight(headHeight);
			column = 0;
			for (int i = 0; i < dto.getYears().size(); i++) {
				column++;
				createCell(titleRow2, column, dto.getYears().get(i), header);
			}

			setRegionStyle(sheet, titleRange1, styles.get("header"));
			setRegionStyle(sheet, titleRowRange, styles.get("header"));

			// 冻结
			sheet.createFreezePane(0, 3, 0, 3);

			XSSFCellStyle data = styles.get("data");

			for (int i = 0; i < dto.getList().size(); i++) {
				CIndicationInfoVO vo = dto.getList().get(i);

				Row dataRow = sheet.createRow(3 + i);
				dataRow.setHeightInPoints(dataHeight);

				column = 0;
				createCell(dataRow, column, vo.getAreaName(), data);
				for (int y = 0; y < dto.getYears().size(); y++) {
					String year = dto.getYears().get(y);
					if (vo.getTotals() == null || !vo.getTotals().containsKey(year)) {
						vo.getTotals().put(year, "0");
					}
					column++;
					createCell(dataRow, column, vo.getTotals().get(year), data);
				}

			}

			autoColumnWidthForChineseChar(sheet, 0, titleSize + 1, (minWidth / 2 * 3), (minWidth / 2 * 3));

		} finally {
			writeToOut(wb, out);
		}

	}

	@Override
	public void exportReportGrowth(OutputStream out, CIndicationInfo req, List<CIndicationInfoDTO> list) {
		

		// TODO Auto-generated method stub

		// TODO Auto-generated method stub

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "地理标志同比增长率报表";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);
			
			XSSFCellStyle header=styles.get("header");
			XSSFCellStyle data=styles.get("data");

			Row titleRow0 = sheet.createRow(0);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(0);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 6;
			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(),0, titleSize-1));
			
			
			Row titleRow1 = sheet.createRow(1);
			titleRow1.setHeight(headHeight);
			
			createCell(titleRow1, 0, "对比地区", header);
			
			CellRangeAddress areaRegion = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum()+1, 0, 0);
			sheet.addMergedRegion(areaRegion);
			
			
			createCell(titleRow1, 1, "对比数据", header);

			createCell(titleRow1, 2, "地理标志产品公告量(件)", header);
			CellRangeAddress aplRegion = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum()+1, 2, 2);
			sheet.addMergedRegion(aplRegion);
			
			createCell(titleRow1, 3, "核准企业(家)", header);
			CellRangeAddress regRegion = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum()+1, 3, 3);
			sheet.addMergedRegion(regRegion);
			
			createCell(titleRow1, 4, "农产品地址标志登记量(件)", header);
			CellRangeAddress actRegion = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum()+1, 4, 4);
			sheet.addMergedRegion(actRegion);
			
			createCell(titleRow1, 5, "地址标志商标注册量(件)", header);
			CellRangeAddress actRegion2 = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum()+1, 5, 5);
			sheet.addMergedRegion(actRegion2);
			
			Row titleRow2 = sheet.createRow(2);
			titleRow2.setHeight(headHeight);
			createCell(titleRow2, 1, "对比周期", header);
			
			// 冻结
			sheet.createFreezePane(0, 3, 0, 3);
			
			int column=0;
			int row=2;
			for(int i=0;i<list.size();i++) {
				CIndicationInfoDTO vo=list.get(i);
				
				
				row++;
				Row dataRow = sheet.createRow(row);
				dataRow.setHeightInPoints(dataHeight);
				column = 0;
				doCreateCellOneRowHv(dataRow, column, vo.getItem1(), data);

				column = 0;
				row++;
				Row dataRow2 = sheet.createRow(row);
				dataRow2.setHeightInPoints(dataHeight);
				doCreateCellOneRowHv(dataRow2, column, vo.getItem2(), data);

				column = 0;
				row++;
				Row dataRow3 = sheet.createRow(row);
				dataRow3.setHeightInPoints(dataHeight);
				doCreateCellOneRowHv(dataRow3, column, vo.getGrowth(), data);
				
				
			}
			

			setRegionStyle(sheet, aplRegion, styles.get("header"));
			setRegionStyle(sheet, regRegion, styles.get("header"));
			setRegionStyle(sheet, actRegion, styles.get("header"));
			setRegionStyle(sheet, areaRegion, styles.get("header"));
			

			autoColumnWidthForChineseChar(sheet, 0, titleSize, minWidth);
			

		} finally {
			writeToOut(wb, out);
		}

	
	}
	

	private void doCreateCellOneRowHv(Row dataRow, int column, CIndicationInfoVO item, XSSFCellStyle style) {
		
		createCell(dataRow, column++, item.getAreaName(), style);
		createCell(dataRow, column++, item.getCompareRate(), style);
		
		Map<String,String>map=item.getTotals();
		createCell(dataRow, column++, map.get("totalCnt1"), style);
		createCell(dataRow, column++, map.get("totalCnt2"), style);
		createCell(dataRow, column++, map.get("totalCnt3"), style);
		createCell(dataRow, column++, map.get("totalCnt4"), style);
		
		
		
		
	}

	@Override
	public void exportReportHzqy(OutputStream out, CIndicationInfo req, CIndicationInfoDTO dto) {

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "地理标志保护产品拥有量";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);

			int column = 0;
			int row = 0;
			Row titleRow0 = sheet.createRow(row);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(column);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 0;
			if (dto.getYears() != null && dto.getYears().size() > 0) {
				int size = dto.getYears().size();
				titleSize = titleSize + size * 2;
			}

			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(
					new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(), column, titleSize));

			row++;
			Row titleRow1 = sheet.createRow(row);
			titleRow1.setHeight(headHeight);
			String val = "地区";
			XSSFCellStyle header = styles.get("header");
			createCell(titleRow1, column, val, header);
			CellRangeAddress titleRowRange = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum() + 2, 0,
					0);
			sheet.addMergedRegion(titleRowRange);

			val = "统计时期";
			if (StringUtils.isNotBlank(req.getCountTimeStr())) {
				val = req.getCountTimeStr();
			}
			column++;
			createCell(titleRow1, column, val, header);
			CellRangeAddress titleRange1 = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum(), column,
					titleSize);
			sheet.addMergedRegion(titleRange1);

			row++;
			Row titleRow2 = sheet.createRow(row);
			titleRow2.setHeight(headHeight);
			column = -1;
			for (int i = 0; i < dto.getYears().size(); i++) {
				column = column + 2;
				createCell(titleRow2, column, dto.getYears().get(i), header);
				CellRangeAddress range = new CellRangeAddress(titleRow2.getRowNum(), titleRow2.getRowNum(), column,
						column + 1);
				sheet.addMergedRegion(range);
			}

			row++;
			Row titleRow3 = sheet.createRow(row);
			titleRow3.setHeight(headHeight);
			column = 1;
			for (int i = 0; i < dto.getYears().size(); i++) {
				createCell(titleRow3, column++, "地标数量", header);
				createCell(titleRow3, column++, "核准企业数", header);
			}

			setRegionStyle(sheet, titleRange1, styles.get("header"));
			setRegionStyle(sheet, titleRowRange, styles.get("header"));

			// 冻结
			sheet.createFreezePane(0, 4, 0, 4);

			XSSFCellStyle data = styles.get("data");

			for (int i = 0; i < dto.getList().size(); i++) {
				CIndicationInfoVO vo = dto.getList().get(i);

				Row dataRow = sheet.createRow(4 + i);
				dataRow.setHeightInPoints(dataHeight);

				column = 0;
				createCell(dataRow, column, vo.getAreaName(), data);
				for (int y = 0; y < dto.getYears().size(); y++) {
					String year = dto.getYears().get(y);
					if (vo.getTotals() == null || !vo.getTotals().containsKey(year)) {
						vo.getTotals().put(year, "0");
					}
					if (vo.getHzqyCounts() == null || !vo.getHzqyCounts().containsKey(year)) {
						vo.getHzqyCounts().put(year, 0L);
					}
					column++;
					createCell(dataRow, column, vo.getTotals().get(year), data);
					column++;
					createCell(dataRow, column, vo.getHzqyCounts().get(year), data);
				}

			}

			autoColumnWidthForChineseChar(sheet, 0, titleSize + 1, (minWidth / 2 * 3), (minWidth / 2 * 3));

		} finally {
			writeToOut(wb, out);
		}

	}

	@Override
	public void exportReportFarm(OutputStream out, CIndicationInfo req, CIndicationInfoDTO dto) {

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "农产品地理标志拥有量";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);

			int column = 0;
			int row = 0;
			Row titleRow0 = sheet.createRow(row);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(column);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 0;
			if (dto.getYears() != null && dto.getYears().size() > 0) {
				int size = dto.getYears().size();
				titleSize = titleSize + size;
			}

			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(
					new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(), column, titleSize));

			row++;
			Row titleRow1 = sheet.createRow(row);
			titleRow1.setHeight(headHeight);
			String val = "地区";
			XSSFCellStyle header = styles.get("header");
			createCell(titleRow1, column, val, header);
			CellRangeAddress titleRowRange = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum() + 1, 0,
					0);
			sheet.addMergedRegion(titleRowRange);

			val = "统计时期";
			if (StringUtils.isNotBlank(req.getCountTimeStr())) {
				val = req.getCountTimeStr();
			}
			column++;
			createCell(titleRow1, column, val, header);
			CellRangeAddress titleRange1 = new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum(), column,
					titleSize);
			sheet.addMergedRegion(titleRange1);

			row++;
			Row titleRow2 = sheet.createRow(row);
			titleRow2.setHeight(headHeight);
			column = 0;
			for (int i = 0; i < dto.getYears().size(); i++) {
				column++;
				createCell(titleRow2, column, dto.getYears().get(i), header);
			}

			setRegionStyle(sheet, titleRange1, styles.get("header"));
			setRegionStyle(sheet, titleRowRange, styles.get("header"));

			// 冻结
			sheet.createFreezePane(0, 3, 0, 3);

			XSSFCellStyle data = styles.get("data");

			for (int i = 0; i < dto.getList().size(); i++) {
				CIndicationInfoVO vo = dto.getList().get(i);

				Row dataRow = sheet.createRow(3 + i);
				dataRow.setHeightInPoints(dataHeight);

				column = 0;
				createCell(dataRow, column, vo.getAreaName(), data);
				for (int y = 0; y < dto.getYears().size(); y++) {
					String year = dto.getYears().get(y);
					if (vo.getTotals() == null || !vo.getTotals().containsKey(year)) {
						vo.getTotals().put(year, "0");
					}
					column++;
					createCell(dataRow, column, vo.getTotals().get(year), data);
				}

			}

			autoColumnWidthForChineseChar(sheet, 0, titleSize + 1, (minWidth / 2 * 3), (minWidth / 2 * 3));

		} finally {
			writeToOut(wb, out);
		}

	}

	@Override
	public void exportReportMarkRank(OutputStream out, CIndicationInfo req, List<CIndicationInfoVO> list) {
		// TODO Auto-generated method stub

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "地理标志商标排名统计报表";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);
			XSSFCellStyle header = styles.get("header");
			XSSFCellStyle data = styles.get("data");

			Row titleRow0 = sheet.createRow(0);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(0);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 3;
			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(), 0, titleSize - 1));

			Row titleRow1 = sheet.createRow(1);
			titleRow1.setHeightInPoints(dataHeight);
			String val = "统计时期";
			if (StringUtils.isNotBlank(req.getCountTimeStr())) {
				val = req.getCountTimeStr();
			}
			createCell(titleRow1, 0, val, header);

			sheet.addMergedRegion(new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum(), 0, titleSize - 1));

			
			Row titleRow2 = sheet.createRow(2);
			titleRow2.setHeightInPoints(dataHeight);
			createCell(titleRow2, 0, "排名", header);
			createCell(titleRow2, 1, "地区", header);
			createCell(titleRow2, 2, "地理标志作为集体商标、证明商标有效量", header);
			
			// 冻结
			sheet.createFreezePane(0, 3, 0, 3);
			
			for (int i = 0; i < list.size(); i++) {
				CIndicationInfoVO vo = list.get(i);

				Row dataRow = sheet.createRow(3 + i);
				dataRow.setHeightInPoints(dataHeight);
				
				createCell(dataRow, 0, vo.getRanking(), data);
				createCell(dataRow, 1, vo.getAreaName(), data);
				createCell(dataRow, 2, vo.getNumber(), data);
				
			}

			autoColumnWidthForChineseChar(sheet, 0, titleSize + 1, (minWidth), (minWidth * 4));

		} finally {
			writeToOut(wb, out);
		}

	}

	@Override
	public void exportReportAddrRank(OutputStream out, CIndicationInfo req, List<CIndicationInfoVO> list) {

		// TODO Auto-generated method stub

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "地理标志保护产品排名统计报表";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);
			XSSFCellStyle header = styles.get("header");
			XSSFCellStyle data = styles.get("data");

			Row titleRow0 = sheet.createRow(0);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(0);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 3;
			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(), 0, titleSize - 1));

			Row titleRow1 = sheet.createRow(1);
			titleRow1.setHeightInPoints(dataHeight);
			String val = "统计时期";
			if (StringUtils.isNotBlank(req.getCountTimeStr())) {
				val = req.getCountTimeStr();
			}
			createCell(titleRow1, 0, val, header);

			sheet.addMergedRegion(new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum(), 0, titleSize - 1));

			
			Row titleRow2 = sheet.createRow(2);
			titleRow2.setHeightInPoints(dataHeight);
			createCell(titleRow2, 0, "排名", header);
			createCell(titleRow2, 1, "地区", header);
			createCell(titleRow2, 2, "地理标志产品累计批准量", header);
			
			// 冻结
			sheet.createFreezePane(0, 3, 0, 3);
			
			for (int i = 0; i < list.size(); i++) {
				CIndicationInfoVO vo = list.get(i);

				Row dataRow = sheet.createRow(3 + i);
				dataRow.setHeightInPoints(dataHeight);
				
				createCell(dataRow, 0, vo.getRanking(), data);
				createCell(dataRow, 1, vo.getAreaName(), data);
				createCell(dataRow, 2, vo.getNumber(), data);
				
			}

			autoColumnWidthForChineseChar(sheet, 0, titleSize + 1, (minWidth), (minWidth * 4));

		} finally {
			writeToOut(wb, out);
		}

	
	}

	@Override
	public void exportReportFarmRank(OutputStream out, CIndicationInfo req, List<CIndicationInfoVO> list) {


		// TODO Auto-generated method stub

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "农产品地理标志全国排名统计报表";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);
			XSSFCellStyle header = styles.get("header");
			XSSFCellStyle data = styles.get("data");

			Row titleRow0 = sheet.createRow(0);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(0);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 3;
			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(), 0, titleSize - 1));

			Row titleRow1 = sheet.createRow(1);
			titleRow1.setHeightInPoints(dataHeight);
			String val = "统计时期";
			if (StringUtils.isNotBlank(req.getCountTimeStr())) {
				val = req.getCountTimeStr();
			}
			createCell(titleRow1, 0, val, header);

			sheet.addMergedRegion(new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum(), 0, titleSize - 1));

			
			Row titleRow2 = sheet.createRow(2);
			titleRow2.setHeightInPoints(dataHeight);
			createCell(titleRow2, 0, "排名", header);
			createCell(titleRow2, 1, "地区", header);
			createCell(titleRow2, 2, "农产品地理标志累计登记量", header);
			
			// 冻结
			sheet.createFreezePane(0, 3, 0, 3);
			
			for (int i = 0; i < list.size(); i++) {
				CIndicationInfoVO vo = list.get(i);

				Row dataRow = sheet.createRow(3 + i);
				dataRow.setHeightInPoints(dataHeight);
				
				createCell(dataRow, 0, vo.getRanking(), data);
				createCell(dataRow, 1, vo.getAreaName(), data);
				createCell(dataRow, 2, vo.getNumber(), data);
				
			}

			autoColumnWidthForChineseChar(sheet, 0, titleSize + 1, (minWidth), (minWidth * 4));

		} finally {
			writeToOut(wb, out);
		}

	
	
	}

	@Override
	public void export(OutputStream out, CIndicationInfo req, List<CIndicationInfo> list) {
		

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "地理标商标详情统计报表";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);
			XSSFCellStyle header = styles.get("header");
			XSSFCellStyle data = styles.get("data");

			Row titleRow0 = sheet.createRow(0);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(0);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 9;
			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(), 0, titleSize - 1));

			Row titleRow1 = sheet.createRow(1);
			titleRow1.setHeightInPoints(dataHeight);
			createCell(titleRow1, 0, "序号", header);
			createCell(titleRow1, 1, "产品名称", header);
			createCell(titleRow1, 2, "公告号(注册号)", header);
			createCell(titleRow1, 3, "公告时间(注册时间)", header);
			createCell(titleRow1, 4, "公告单位", header);
			createCell(titleRow1, 5, "申请人", header);
			createCell(titleRow1, 6, "申请人地址", header);
			createCell(titleRow1, 7, "使用商品", header);
			createCell(titleRow1, 8, "商品组别", header);

//			sheet.addMergedRegion(new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum(), 0, titleSize - 1));
			
			// 冻结
			sheet.createFreezePane(0, 2, 0, 2);
			
			for (int i = 0; i < list.size(); i++) {
				CIndicationInfo vo = list.get(i);

				Row dataRow = sheet.createRow(2 + i);
				dataRow.setHeightInPoints(dataHeight);
				
				createCell(dataRow, 0, vo.getId(), data);
				createCell(dataRow, 1, vo.getPron(), data);
				createCell(dataRow, 2, vo.getPubNo(), data);
				createCell(dataRow, 3, vo.getPubDate(), data);
				createCell(dataRow, 4, vo.getPubDw(), data);
				createCell(dataRow, 5, vo.getApplicant(), data);
				createCell(dataRow, 6, vo.getAnddr(), data);
				createCell(dataRow, 7, vo.getSsp(), data);
				createCell(dataRow, 8, vo.getPty(), data);
				
			}

			autoColumnWidthForChineseChar(sheet, 0, titleSize + 1, (minWidth), (minWidth * 4));

		} finally {
			writeToOut(wb, out);
		}

	
	
	
	}
	@Override
	public void export2(OutputStream out, CIndicationInfo req, List<CIndicationInfo> list) {
		

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "地理标志保护产品详情";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);
			XSSFCellStyle header = styles.get("header");
			XSSFCellStyle data = styles.get("data");

			Row titleRow0 = sheet.createRow(0);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(0);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 9;
			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(), 0, titleSize - 1));

			Row titleRow1 = sheet.createRow(1);
			titleRow1.setHeightInPoints(dataHeight);
			createCell(titleRow1, 0, "序号", header);
			createCell(titleRow1, 1, "产品名称", header);
			createCell(titleRow1, 2, "类别", header);
			createCell(titleRow1, 3, "年份", header);
			createCell(titleRow1, 4, "州市", header);
			createCell(titleRow1, 5, "批准公告号", header);
			createCell(titleRow1, 6, "批准公告日", header);
			createCell(titleRow1, 7, "执行标准", header);
			createCell(titleRow1, 8, "标准类型", header);
			createCell(titleRow1, 9, "核准使用企业数量", header);

//			sheet.addMergedRegion(new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum(), 0, titleSize - 1));
			
			// 冻结
			sheet.createFreezePane(0, 2, 0, 2);
			
			for (int i = 0; i < list.size(); i++) {
				CIndicationInfo vo = list.get(i);

				Row dataRow = sheet.createRow(2 + i);
				dataRow.setHeightInPoints(dataHeight);
				
				createCell(dataRow, 0, vo.getId(), data);
				createCell(dataRow, 1, vo.getPron(), data);
				createCell(dataRow, 2, vo.getPty(), data);
				createCell(dataRow, 3, vo.getPubYear(), data);
				createCell(dataRow, 4, vo.getModifyAppCity(), data);
				createCell(dataRow, 5, vo.getPubNo(), data);
				createCell(dataRow, 6, vo.getPubDate(), data);
				createCell(dataRow, 7, "", data);
				createCell(dataRow, 8, "", data);
				createCell(dataRow, 9, vo.getHzqyCounts(), data);
				
			}

			autoColumnWidthForChineseChar(sheet, 0, titleSize + 1, (minWidth), (minWidth * 4));

		} finally {
			writeToOut(wb, out);
		}

		
	
	
	}
	
	
	@Override
	public void export3(OutputStream out, CIndicationInfo req, List<CIndicationInfo> list) {
		

		SXSSFWorkbook wb = new SXSSFWorkbook(500);

		try {
			// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
			// response.setCharacterEncoding("utf-8");
			short headHeight = 30 * 20;
			int minWidth = "四个字宽".getBytes().length * 256;
			String title = "农产品地理标志详情";

			int dataHeight = 30;

			SXSSFSheet sheet = wb.createSheet();
			wb.setSheetName(0, title);
			sheet.trackAllColumnsForAutoSizing();

			Map<String, XSSFCellStyle> styles = createStyles(wb);
			XSSFCellStyle header = styles.get("header");
			XSSFCellStyle data = styles.get("data");

			Row titleRow0 = sheet.createRow(0);
			titleRow0.setHeightInPoints(dataHeight);
			Cell titleCell = titleRow0.createCell(0);
			titleCell.setCellStyle(styles.get("title"));
			titleCell.setCellValue(title);

			int titleSize = 6;
			// 合并单元格语法： 开始行、结束行、开始列、结束列
			// 对应代码：new CellRangeAddress(startRowIndex, rowIndex - 1, i, i);
			sheet.addMergedRegion(new CellRangeAddress(titleRow0.getRowNum(), titleRow0.getRowNum(), 0, titleSize - 1));

			Row titleRow1 = sheet.createRow(1);
			titleRow1.setHeightInPoints(dataHeight);
			createCell(titleRow1, 0, "序号", header);
			createCell(titleRow1, 1, "产品名称", header);
			createCell(titleRow1, 2, "产地", header);
			createCell(titleRow1, 3, "产品编号", header);
			createCell(titleRow1, 4, "证书持有者", header);
			createCell(titleRow1, 5, "登记年份", header);

//			sheet.addMergedRegion(new CellRangeAddress(titleRow1.getRowNum(), titleRow1.getRowNum(), 0, titleSize - 1));
			
			// 冻结
			sheet.createFreezePane(0, 2, 0, 2);
			
			for (int i = 0; i < list.size(); i++) {
				CIndicationInfo vo = list.get(i);

				Row dataRow = sheet.createRow(2 + i);
				dataRow.setHeightInPoints(dataHeight);
				
				createCell(dataRow, 0, vo.getId(), data);
				createCell(dataRow, 1, vo.getPron(), data);
				createCell(dataRow, 2, vo.getBhfw(), data);
				createCell(dataRow, 3, vo.getPubNo(), data);
				createCell(dataRow, 4, "", data);
				createCell(dataRow, 5, vo.getPubYear(), data);
				
			}

			autoColumnWidthForChineseChar(sheet, 0, titleSize + 1, (minWidth), (minWidth * 4));

		} finally {
			writeToOut(wb, out);
		}
	}
}
