package com.itf.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.RegionUtil;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
/**
* @ClassName: ExcelUtils
* @Description: 导出Excel工具类
* @date: 2019年4月15日
* @version : V1.0
*
* Modification History:
* Date Author Version Description
* --------------------------------------------------------
*/
public class ExcelUtils {
/**
* @Title: exportSbhz
* @Description: 导出申报汇总
* @param: @param list 申报汇总查询list
* @param: @param version 版本
* @param: @param sheetName Excel名称
* @return: void
* @throws
* @date : 2019年4月15日
*
* Modification History:
* Date Author Version Description
* --------------------------------------------------------
*/
public static void exportSbhz(List<Map<String, Object>> list,Integer version, String sheetName, HttpServletResponse response) {
Map<String, Object> map = new HashMap<String, Object>();
//头部信息
List<String> headValList = new ArrayList<String>();
//头部信息明确赋值
headValList.addAll(Arrays.asList(new String[]{"123","123"}));
List<String> headInfoValList = new ArrayList<String>();
//头部信息辅助信息明确赋值
headInfoValList.addAll(Arrays.asList(new String[]{"456","456"}));
List<String> demoList = null; // 储存器
//存储明细
List<List<String>> realContentList = new ArrayList<List<String>>();
realContentList.add(headInfoValList);
if (list != null && list.size()>0) {
for (Map<String, Object> i : list) {
demoList = new ArrayList<String>();
demoList.add(i.containsKey("xxx") ?i.get("xxx") != null ? i.get("xxx").toString() : "" : "");
........
realContentList.add(demoList);
}
}
map.put("headValList", headValList);
map.put("realContentList", realContentList);
map.put("sheetName", sheetName);
if(version != null && version == 1 ) map.put("excelVersion", "V2007");
exportExcel(map, "sbhz", response); // 调用生成Excel方法
}
/**
* @Title: exportSbmx
* @Description: 导出申报明细
* @param: @param list 申报明细集合
* @param: @param version 版本
* @param: @param sheetName Excel名称
* @return: void
* @throws
* @date : 2019年4月15日
*
* Modification History:
* Date Author Version Description
* -------------------------------------------------------
*/
public static void exportSbmx(List<Map<String, Object>> list, Integer version, String sheetName, HttpServletResponse response) {
Map<String, Object> map = new HashMap<String, Object>();
//头部信息
List<String> headValList = new ArrayList<String>();
//头部信息明确赋值
headValList.addAll(Arrays.asList(new String[]{"789","789"}));
List<String> headInfoValList = new ArrayList<String>();
//头部信息明确赋值
headInfoValList.addAll(Arrays.asList(new String[]{"147","147"}));
List<String> demoList = null; // 储存器
//存储明细
List<List<String>> realContentList = new ArrayList<List<String>>();
realContentList.add(headInfoValList);
if (list != null && list.size()>0) {
for (Map<String, Object> i : list) {
demoList = new ArrayList<String>();
demoList.add(i.containsKey("xxx") ? i.get("xxx") != null ? i.get("xxx").toString() : "" : "");
.........
realContentList.add(demoList);
}
}
map.put("headValList", headValList);
map.put("realContentList", realContentList);
map.put("sheetName", sheetName);
if(version != null && version == 1 ) map.put("excelVersion", "V2007");
exportExcel(map, "sbmx", response); // 调用生成Excel方法
}
/**
* @Title: exportGshz
* @Description: 导出个税汇总
* @param: @param list 个税汇总集合
* @param: @param version 版本
* @return: void
* @throws
* @date : 2019年4月15日
*
* Modification History:
* Date Author Version Description
* --------------------------------------------------------
*/
public static void exportGshz(List<Map<String, Object>> list, Integer version, HttpServletResponse response) {
Map<String, Object> map = new HashMap<String, Object>();
//头部信息
List<String> headValList = new ArrayList<String>();
//头部信息明确赋值
headValList.addAll(Arrays.asList(new String[]{"132","321"}));
List<String> demoList = null; // 储存器
//存储明细
List<List<String>> realContentList = new ArrayList<List<String>>();
if (list != null && list.size()>0) {
for (Map<String, Object> i : list) {
demoList = new ArrayList<String>();
demoList.add(i.containsKey("xxx") ? i.get("xxx") != null ? i.get("xxx").toString() : "" : "");