protected void service(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
String vkpgg_start=request.getParameter("syzk_start");
String vkpgg_end=request.getParameter("syzk_end");
VKpGgQueryBO queryBo=new VKpGgQueryBO();
int rowCount=0;
VKpGgUtil dataUtil=new VKpGgUtil();
Object[][] dataList=new Object[8][27];
dataList=dataUtil.getJXData(queryBo,"syzk");
for(int row=0;row<8;row++)
{
if(dataList[row][0].toString()=="总计")
{
rowCount=row;
    break;
}
}
String[] headerSyzk=new String[]{"使用状况","土 地","房屋构建物","通用设备","专用设备","交通运输设备","电气设备","电子产品及通信设备","仪器仪表及量具","文艺体育设备","图书文物及陈列品","家具用具及其它类","数量合计","价值合计"};
OutputStream out=response.getOutputStream();
HSSFWorkbook wb=new HSSFWorkbook();
HSSFSheet sheet=wb.createSheet("使用状况统计表");
        
                  HSSFRow rowF=sheet.createRow((short)0);
HSSFRow rowS=sheet.createRow((short)1);
sheet.addMergedRegion(new Region(0,(short)0,1,(short)0));
HSSFCell ceF=rowF.createCell((short)0);
ceF.setEncoding(HSSFCell.ENCODING_UTF_16);
ceF.setCellValue(headerSyzk[0].toString());
ceF.setCellStyle(getIntStyle(wb,"String"));
HSSFCell ceS=rowS.createCell((short)0);
ceS.setCellStyle(getIntStyle(wb,"String"));

sheet.addMergedRegion(new Region(0,(short)1,0,(short)3));
HSSFCell cellTD=rowF.createCell((short)1);
cellTD.setEncoding(HSSFCell.ENCODING_UTF_16);
cellTD.setCellValue(headerSyzk[1].toString());
cellTD.setCellStyle(getIntStyle(wb,"String"));
HSSFCell ceTDSL=rowF.createCell((short)2);
    ceTDSL.setCellStyle(getIntStyle(wb,"String"));
HSSFCell ceTDJZ=rowF.createCell((short)3);
ceTDJZ.setCellStyle(getIntStyle(wb,"String"));


sheet.addMergedRegion(new Region(0,(short)4,0,(short)6));
HSSFCell cellFW=rowF.createCell((short)4);
cellFW.setEncoding(HSSFCell.ENCODING_UTF_16);
cellFW.setCellValue(headerSyzk[2].toString());
cellFW.setCellStyle(getIntStyle(wb,"String"));
HSSFCell ceFWSL=rowF.createCell((short)5);
ceFWSL.setCellStyle(getIntStyle(wb,"String"));
HSSFCell ceFWJZ=rowF.createCell((short)6);
ceFWJZ.setCellStyle(getIntStyle(wb,"String"));
    
//     for(int col=7;col<24;col=col+2)
//     {
//      sheet.addMergedRegion(new Region(0,(short)col,0,(short)(col+1)));
//      HSSFCell cellF=rowF.createCell((short)col);
//      cellF.setEncoding(HSSFCell.ENCODING_UTF_16);
//      cellF.setCellValue(headerSyzk[(col-1)/2].toString());
//      cellF.setCellStyle(getIntStyle(wb,"String"));
//      HSSFCell cellS=rowF.createCell((short)(col+1));
//      cellS.setCellStyle(getIntStyle(wb,"String"));     
//     }    

     sheet.addMergedRegion(new Region(0,(short)7,0,(short)8));
     HSSFCell cell31=rowF.createCell((short)7);
     cell31.setEncoding(HSSFCell.ENCODING_UTF_16);
     cell31.setCellValue(headerSyzk[3].toString());
     cell31.setCellStyle(getIntStyle(wb,"String"));    
     HSSFCell cell32=rowF.createCell((short)8);
     cell32.setCellStyle(getIntStyle(wb,"String")); //     sheet.addMergedRegion(new Region(0,(short)9,0,(short)10));
//     HSSFCell cell41=rowF.createCell((short)9);
//     cell41.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cell41.setCellValue(headerSyzk[4].toString());
//     cell41.setCellStyle(getIntStyle(wb,"String"));
//     HSSFCell cell42=rowF.createCell((short)10);
//     cell42.setCellStyle(getIntStyle(wb,"String"));
//  
//     sheet.addMergedRegion(new Region(0,(short)11,0,(short)12));
//     HSSFCell cell51=rowF.createCell((short)11);
//     cell51.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cell51.setCellValue(headerSyzk[5].toString());
//     cell51.setCellStyle(getIntStyle(wb,"String"));
//     HSSFCell cell52=rowF.createCell((short)12);
//     cell52.setCellStyle(getIntStyle(wb,"String"));
//    
//     sheet.addMergedRegion(new Region(0,(short)13,0,(short)14));
//     HSSFCell cell61=rowF.createCell((short)13);
//     cell61.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cell61.setCellValue(headerSyzk[6].toString());
//     cell61.setCellStyle(getIntStyle(wb,"String"));
//     HSSFCell cell62=rowF.createCell((short)14);
//     cell62.setCellStyle(getIntStyle(wb,"String"));
//    
//     sheet.addMergedRegion(new Region(0,(short)15,0,(short)16));
//     HSSFCell cell71=rowF.createCell((short)15);
//     cell71.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cell71.setCellValue(headerSyzk[7].toString());
//     cell71.setCellStyle(getIntStyle(wb,"String"));
//     HSSFCell cell72=rowF.createCell((short)16);
//     cell72.setCellStyle(getIntStyle(wb,"String"));
//    
//     sheet.addMergedRegion(new Region(0,(short)17,0,(short)18));
//     HSSFCell cell81=rowF.createCell((short)17);
//     cell81.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cell81.setCellValue(headerSyzk[8].toString());
//     cell81.setCellStyle(getIntStyle(wb,"String"));
//     HSSFCell cell82=rowF.createCell((short)18);
//     cell82.setCellStyle(getIntStyle(wb,"String"));
//    
//     sheet.addMergedRegion(new Region(0,(short)19,0,(short)20));
//     HSSFCell cell91=rowF.createCell((short)19);
//     cell91.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cell91.setCellValue(headerSyzk[9].toString());
//     cell91.setCellStyle(getIntStyle(wb,"String"));
//     HSSFCell cell92=rowF.createCell((short)20);
//     cell92.setCellStyle(getIntStyle(wb,"String"));
//    
//     sheet.addMergedRegion(new Region(0,(short)21,0,(short)22));
//     HSSFCell cell101=rowF.createCell((short)21);
//     cell101.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cell101.setCellValue(headerSyzk[10].toString());
//     cell101.setCellStyle(getIntStyle(wb,"String"));
//     HSSFCell cell102=rowF.createCell((short)22);
//     cell102.setCellStyle(getIntStyle(wb,"String"));
//    
//     sheet.addMergedRegion(new Region(0,(short)23,0,(short)24));
//     HSSFCell cell111=rowF.createCell((short)23);
//     cell111.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cell111.setCellValue(headerSyzk[11].toString());
//     cell111.setCellStyle(getIntStyle(wb,"String"));
//     HSSFCell cell112=rowF.createCell((short)24);
//     cell112.setCellStyle(getIntStyle(wb,"String"));    
//    
//     sheet.addMergedRegion(new Region(0,(short)25,1,(short)25));
//     HSSFCell cellSLF=rowF.createCell((short)25);
//     cellSLF.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cellSLF.setCellValue(headerSyzk[12].toString());
//     cellSLF.setCellStyle(getIntStyle(wb,"String"));    
//     HSSFCell cellSLS=rowS.createCell((short)25);
//     cellSLF.setCellStyle(getIntStyle(wb,"String"));
//    
//     sheet.addMergedRegion(new Region(0,(short)26,0,(short)26));
//     HSSFCell cellJZF=rowF.createCell((short)26);
//     cellJZF.setEncoding(HSSFCell.ENCODING_UTF_16);
//     cellJZF.setCellValue(headerSyzk[13].toString());
//     cellJZF.setCellStyle(getIntStyle(wb,"String"));    
//     HSSFCell cellJZS=rowS.createCell((short)26);
//     cellJZS.setCellStyle(getIntStyle(wb,"String"));
    
for(int col=1;col<25;col++)
{
HSSFCell cell=rowS.createCell((short)col);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
if(col==1||col==4)
{
cell.setCellValue("面积");
}
if(col==2||col==5||col==7||col==9||col==11||col==13||col==15||col==17||col==19||col==21||col==23)
{
cell.setCellValue("数量");
}
if(col==3||col==6||col==8||col==10||col==12||col==14||col==16||col==18||col==20||col==22||col==24)
{
cell.setCellValue("价值");
}
cell.setCellStyle(getIntStyle(wb,"String"));
}

if(rowCount!=0)
{
for(int i=0;i<=rowCount;i++)
{
HSSFRow row=sheet.createRow((short)(i+2));
for(int j=0;j<27;j++)
{
HSSFCell cell=row.createCell((short)j);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
if(dataList[i][j] instanceof String) 
{
cell.setCellValue(dataList[i][j].toString());
cell.setCellStyle(getIntStyle(wb,"String"));
}
if(dataList[i][j] instanceof Long)
{
cell.setCellValue(Long.parseLong(dataList[i][j].toString()));
cell.setCellStyle(getIntStyle(wb,"Long"));
}
if(dataList[i][j] instanceof Integer)
{
cell.setCellValue(Integer.parseInt(dataList[i][j].toString()));
cell.setCellStyle(getIntStyle(wb,"Integer"));
}
if(dataList[i][j] instanceof Double)
{
cell.setCellValue(Double.parseDouble(dataList[i][j].toString()));
cell.setCellStyle(getIntStyle(wb,"Double"));
}
if(dataList[i][j] instanceof Date)
{
cell.setCellValue(dataList[i][j].toString());
cell.setCellStyle(getIntStyle(wb,"Date"));
}
}
}
wb.write(out);
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setHeader("Content-disposition","attachment;filename="+URLEncoder.encode("使用状况统计表","UTF-8")+".xls");
}

}

POI导出问题 用servlet写了个poi导出发现只加上注释上的句子程序就会出错,不但弹不出导出excel的对话框,而且页面不审乱码,程序跟踪调试都没有错误