Excel文档的生成和压缩

     //压缩EXCEL文件

   //上门列表导出,生成压缩文件

    public String doorVisitOutXls() throws Exception{
        int recCount = doorVisitService.getDoorVisitListCount(isShow,beginTime, endTime, getComIDOfJ(), staId, this.getSexps());
        if (recCount <= 0) {
            downloadFile = java.net.URLEncoder.encode("无上门回访单记录.txt","UTF-8");
            inputStream = new ByteArrayInputStream("无上门回访单记录下载".getBytes());
            return SUCCESS;
        }
        //记录数大于零
        String fileName="";
        List<Map>outList = null;
        //创建文件目录
        sroMap = doorVisitService.getDoorVisitSerOther();
        vsiMap = doorVisitService.getDoorVisitCircs();
        vsoMap = doorVisitService.getDoorVisitOtherwise();
        String savePath = getRegparamService().getPath(9) + this.getEmpIDOfJ();
        File dstPath = new File(savePath);
        if (!dstPath.exists()) dstPath.mkdirs();
        //记录数大于零
        setPageCount(recCount,true);
        String fileNames[] =  new String[pageCount];
        //生成xls文件    
        DoorVisitOutXls outXls =  new DoorVisitOutXls();
        for(int pageNo = 1;pageNo <= pageCount;pageNo++){
            outList = doorVisitService.getDoorVisitList(isShow,beginTime, endTime, pageNo, pageSize, getComIDOfJ(), staId, this.getSexps());
            fileName = savePath + "/SMHFD_" + pageNo + "[" + outXls.toDateStr(new Date(),"yyMMddHHmmss") + "].xls";
            outXls.outDvsXLS(outList, fileName,sroMap,vsiMap,vsoMap);
            fileNames[pageNo-1] = fileName;
        }
        //压缩xls文件
        fileName = "上门回访单[" + outXls.toDateStr(new Date(),"yyMMddHHmmss") + "].zip";
        String zipFile = savePath + "/" + fileName;
        FileZip.compress(fileNames,zipFile);
        //删除xls文件
        File xlsFile = null;
        for(int i = 0; i < fileNames.length; i++){
            xlsFile = new File(fileNames[i]);
            if(xlsFile.exists()) xlsFile.delete();        
        }
        //读取下载文件
        File file = new File(zipFile);
        if(file.exists()){
            downloadFile = java.net.URLEncoder.encode(fileName,"UTF-8");
            inputStream = new FileInputStream(file);
        }
        return SUCCESS;

    } 

//生成EXCEL文件的工具类

  package com.company.item.desc;


import java.io.File;
import java.io.FileOutputStream;
import java.util.List;
import java.util.Map;

import org.apache.poi.hssf.usermodel.*;

public class CreateEXCEL {
    
    public static void main(String[] args) {
    //Map sroMap,Map vsiMap,Map vsoMap,List<Map>dvsList,
    CreateEXCEL.outDvsXLS("D:/WorkSpaces/CSTSystem/CreateEXCEL.xls");
    }
    public static void outDvsXLS(String fileName){
    String switchStr = "";//定义一个公共遍历接收处理列标题,以其匹配相应的数据
    //CrmDoorVisit crmDoorVisit;
    //CrmClientS crmClientS;
    File outfile = new File(fileName);
      if (outfile.exists()){//判断是否存在此文件,如果存在则删除
      outfile.delete();
      }
    //定义生成的EXCEL列标题
    String[] headerNames={"识别编码","客户名称","联系地址","联系人","固定电话","移动电话","所属行政局",
                          "管辖人员","服务类别","多产品否","服务类别其他选项","服务注销","回访单号",
                          "纸质单号","服务产品","产品运行情况","处理结果","服务总体评价","服务不满原因",
                          "产品总体评价","产品不满原因","回访开始","开始时间","开始来电","回访结束",
                          "结束时间","结束来电","回访情况","回访完成","回访人员","顾客签字","年度次数",
                          "单独回访","回访其他选项","是否派工","派工说明","派遣日期","派遣人员",
                          "派工完成","派工日期","派工人员","是否打印","打印日期","打印人员","计单工作量",
                          "是否交单","交单时间","收单人员","审核情况","审核日期","审核人员","是否跟踪",
                          "文件","计划单号","备注","是否作废","服务公司","创建日期","创建人员",
                          "修改日期","修改人员"};
    try{
        //开始输出Execl                  
        String sheetName="上门回访信息";
        HSSFWorkbook workbook = new HSSFWorkbook();   
        HSSFSheet sheet = workbook.createSheet();   
        workbook.setSheetName(0, sheetName);
        //风格
        HSSFCellStyle cs = workbook.createCellStyle();
        HSSFCellStyle csDate = workbook.createCellStyle();
        //字体
        HSSFFont font = workbook.createFont();
        font.setFontHeightInPoints((short)9);
        font.setFontName("宋体");
        cs.setFont(font);
        csDate.setFont(font);
        //日期格式
        short df = workbook.createDataFormat().getFormat("yyyy-MM-dd hh:mm:ss");
        csDate.setDataFormat(df);
        //
        HSSFRow row = sheet.createRow((short) 0);   
        HSSFCell cell;
        int iColumn = 0;

        iColumn = headerNames.length;//列数为,标题数组的长度,一个标题占一列
        for(int i = 0;i < iColumn;i++){            
            cell = row.createCell((short) (i));   
            cell.setCellType(HSSFCell.CELL_TYPE_STRING); //设置列类型
            cell.setCellStyle(cs);//设置列样式
            cell.setCellValue(headerNames[i]);//设置列标题
        }
        
        //以上代码生成一个有列标题的空EXCEL文档
        //通过处理数据并写入表格内容
        int j = 0;//设置一个行变量,初始值为0
        for(int i=0; i<5; i++){//对传入的list数据进行遍历//dvsList
            //crmDoorVisit = (CrmDoorVisit)dvsList.get(i).get("crmDoorVisit");
            //crmClientS = (CrmClientS)dvsList.get(i).get("crmClientS");
            row = sheet.createRow((short)i + 1);//没变量一次加一行
            j = 0;
            //识别编码
            //switchStr = crmDoorVisit.getDvsClmCode();//获取对应的数据
            switchStr = "52146255874002354";
            cell=row.createCell((short) j++);//在当前字段下加一Cell,(格)
            cell.setCellStyle(cs);//设置样式
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);//设置类型
            cell.setCellValue(switchStr);//
            //客户名称                
            //switchStr = crmDoorVisit.getCrmClientM().getClmName();
            switchStr = "张三";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //联系地址
            //switchStr=crmDoorVisit.getDvsClmAddress();
            switchStr = "四川省成都市";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //联系人
            //switchStr=crmDoorVisit.getDvsClmContact();
            switchStr = "李四";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //固定电话
            //switchStr=crmDoorVisit.getDvsClmPhone();
            switchStr = "028-6425897";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //移动电话
            //switchStr=crmDoorVisit.getDvsClmMobile();
            switchStr = "18728474132";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //所属行政局
            //if(crmDoorVisit.getCrmClientM().getCrmStation()!=null){switchStr=crmDoorVisit.getCrmClientM().getCrmStation().getStaName();}else{switchStr="";}
            switchStr="四川省成都市税务局";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //管辖人员
            //if(crmClientS.getComEmployeeByClsSerMan()!=null){switchStr=crmClientS.getComEmployeeByClsSerMan().getEmpName();}else{switchStr="";}
            //if(crmClientS==null){switchStr="";}
            switchStr="王五";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //服务类别
            //if(crmClientS.getCrmSerType()!=null){switchStr=crmClientS.getCrmSerType().getSrtName();}else{switchStr="";}
            //if(crmClientS==null){switchStr="";}
            switchStr = "税务费收缴";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //多产品否
            //if(this.nullToStr(crmClientS.getClsMany()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            //if(crmClientS==null){switchStr="";}
            switchStr = "否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);                
            //服务类别其他
        //    switchStr=this.getMapStr(sroMap,crmClientS.getClsOtherwise());
            //if(crmClientS==null){switchStr="";}
            switchStr = "55";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //服务注销
            //if(this.nullToStr(crmClientS.getClsLogout()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            //if(crmClientS==null){switchStr="";}
            switchStr = "否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //回访单号
            //switchStr=crmDoorVisit.getDvsCode();
            switchStr = "25897";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //纸质单号
            //switchStr=crmDoorVisit.getDvsPaperNo();
            switchStr = "1254879325888";
                
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //服务产品
            //if(crmDoorVisit.getCrmSerType()!=null){switchStr=crmDoorVisit.getCrmSerType().getSrtName();}else{switchStr="";}
            switchStr = "水费";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //产品运行情况
            //switchStr=crmDoorVisit.getDvsRunCircs();
            switchStr = "良好";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //处理结果
            //switchStr=crmDoorVisit.getDvsSolve();
            switchStr = "完成";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //服务总体评价
            //if(crmDoorVisit.getCrmSvcApproveByDvsApprove()!=null){switchStr=crmDoorVisit.getCrmSvcApproveByDvsApprove().getSvpName();}else{switchStr="";}
            switchStr = "一般";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //服务不满原因
        //    switchStr=crmDoorVisit.getDvsApvReason();
            switchStr = "税收太高";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //产品总体评价
            //if(crmDoorVisit.getCrmSvcApproveByDvsClpApprove()!=null){switchStr=crmDoorVisit.getCrmSvcApproveByDvsClpApprove().getSvpName();}else{switchStr="";}
            switchStr = "一般";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //产品不满原因
            //switchStr=crmDoorVisit.getDvsClpReason();    
            switchStr = "服务态度有点不好";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //回访开始
            //if(this.nullToStr(crmDoorVisit.getDvsBegin()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            switchStr = "否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //开始时间
            //switchStr=this.toDateStr(crmDoorVisit.getDvsBtime(),"yyyy-MM-dd HH:mm:ss");
            switchStr = "2015-11-30 17:05:22";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //开始来电
            //switchStr=crmDoorVisit.getDvsBphone();
            switchStr = "18728474132";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //回访结束
            //if(this.nullToStr(crmDoorVisit.getDvsEnd()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            switchStr="否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //结束时间
            //switchStr=this.toDateStr(crmDoorVisit.getDvsEtime(),"yyyy-MM-dd HH:mm:ss");
            switchStr = "2015-11-30 17:06:22";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //结束来电
            //switchStr=crmDoorVisit.getDvsEphone();
            switchStr = "8728474132";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //回访情况
            //switchStr=this.getMapStr(vsiMap,crmDoorVisit.getDvsCircs());
            switchStr = "一般";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //回访完成
            //if(this.nullToStr(crmDoorVisit.getDvsDone()).equalsIgnoreCase("1")){}else{switchStr="否";}
            switchStr="是";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //回访人员
            //if(crmDoorVisit.getComEmployeeByDvsVisitor()!=null){switchStr=crmDoorVisit.getComEmployeeByDvsVisitor().getEmpName();}else{switchStr="";}
            switchStr="赵六";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //顾客签字
            //switchStr=crmDoorVisit.getDvsClient();
            switchStr = "钱柒";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //年度次数
        //    switchStr=toLongStr(crmDoorVisit.getDvsTimes());
            switchStr = "20";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //单独回访
            //if(this.nullToStr(crmDoorVisit.getDvsAlone()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            switchStr="否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //回访其他选项
            //switchStr=this.getMapStr(vsoMap,crmDoorVisit.getDvsOtherwise());
            switchStr="545";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //是否派工
            //if(this.nullToStr(crmDoorVisit.getDvsSend()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            switchStr="否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //派工说明
            //switchStr=crmDoorVisit.getDvsSendSay();
            switchStr = "必须解决";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //派遣日期
            //switchStr=this.toDateStr(crmDoorVisit.getDvsSendTime(),"yyyy-MM-dd HH:mm:ss");
            switchStr = "2015-11-30 12:06:88";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //派遣人员
            //if(crmDoorVisit.getComEmployeeByDvsAssigner()!=null){switchStr=crmDoorVisit.getComEmployeeByDvsAssigner().getEmpName();}else{switchStr="";}
            switchStr = "孙八";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //派工完成
        //    if(this.nullToStr(crmDoorVisit.getDvsDispatch()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            switchStr="否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //派工日期
            //switchStr=this.toDateStr(crmDoorVisit.getDvsDispDate(),"yyyy-MM-dd HH:mm:ss");
            switchStr = "2015-12-01 13:11:25";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //派工人员
            //if(crmDoorVisit.getComEmployeeByDvsDispatcher()!=null){switchStr=crmDoorVisit.getComEmployeeByDvsDispatcher().getEmpName();}else{switchStr="";}
            switchStr="陈九";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //是否打印
            //if(this.nullToStr(crmDoorVisit.getDvsPrint()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            switchStr="否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //打印日期
            //switchStr=this.toDateStr(crmDoorVisit.getDvsPrintTime(),"yyyy-MM-dd HH:mm:ss");
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //打印人员
            //if(crmDoorVisit.getComEmployeeByDvsPrinter()!=null){switchStr=crmDoorVisit.getComEmployeeByDvsPrinter().getEmpName();}else{switchStr="";}
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //计单工作量
            //switchStr=toDoubleStr(crmDoorVisit.getDvsWorkload());
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //是否交单
            //if(this.nullToStr(crmDoorVisit.getDvsTender()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            switchStr="否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //交单时间
            //switchStr=this.toDateStr(crmDoorVisit.getDvsTndTime(),"yyyy-MM-dd HH:mm:ss");
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //收单人员
            //if(crmDoorVisit.getComEmployeeByDvsTenderee()!=null){switchStr=crmDoorVisit.getComEmployeeByDvsTenderee().getEmpName();}else{switchStr="";}
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //审核情况
            //if(crmDoorVisit.getComVerify()!=null){switchStr=crmDoorVisit.getComVerify().getVfyName();}else{switchStr="";}
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //审核日期
            //switchStr=this.toDateStr(crmDoorVisit.getDvsVdate(),"yyyy-MM-dd HH:mm:ss");
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //审核人员
            //if(crmDoorVisit.getComEmployeeByDvsCensor()!=null){switchStr=crmDoorVisit.getComEmployeeByDvsCensor().getEmpName();}else{switchStr="";}
            switchStr="胡一";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //是否跟踪
            //if(this.nullToStr(crmDoorVisit.getDvsScout()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            switchStr="是";
            switchStr="否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //文件        
            //switchStr=this.toLongStr(crmDoorVisit.getDvsAisino());
            switchStr = "6484";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //计划单号
            //if(crmDoorVisit.getCrmPlanVisit()!=null){switchStr=toLongStr(crmDoorVisit.getCrmPlanVisit().getPlvId());}else{switchStr="";}
            switchStr="5868686";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //备注
            //switchStr=crmDoorVisit.getDvsRemark();
            switchStr="复核单要8455";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //是否作废
        //    if(this.nullToStr(crmDoorVisit.getDvsFlag()).equalsIgnoreCase("1")){switchStr="是";}else{switchStr="否";}
            switchStr="否";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //服务公司
            //switchStr=crmDoorVisit.getComCompany().getComName();
            switchStr="中国有限公司";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //创建人员
            //if(crmDoorVisit.getComEmployeeByDvsCreator()!=null){switchStr=crmDoorVisit.getComEmployeeByDvsCreator().getEmpName();}else{switchStr="";}
            switchStr = "1551";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //创建时间
            //switchStr=this.toDateStr(crmDoorVisit.getDvsCdate(),"yyyy-MM-dd HH:mm:ss");
            switchStr = "2015-08-26";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //修改人员
            //if(crmDoorVisit.getComEmployeeByDvsMender()!=null){switchStr=crmDoorVisit.getComEmployeeByDvsMender().getEmpName();}else{switchStr="";}
            switchStr="";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
            //修改时间
            //switchStr=this.toDateStr(crmDoorVisit.getDvsMdate(),"yyyy-MM-dd HH:mm:ss");
            switchStr = "2015-11-30 14:10:36";
            cell=row.createCell((short) j++);
            cell.setCellStyle(cs);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(switchStr);
        }        
        //调整列宽
//        for(int i = 0; i < headerNames.length; i++){
//            //sheet.autoSizeColumn((short)i);
//        }
        FileOutputStream fileOut = new FileOutputStream(fileName);
        System.out.println(fileName.toString());
        workbook.write(fileOut);
        fileOut.flush();
        fileOut.close();            
    }catch(Exception ex){
        System.out.println(ex.toString());
    }
}
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值