**如下:
/**
* 賬單明細匯出
//匯出
// 第一步,建立乙個webbook,對應乙個excel檔案
hssfworkbook wb = new hssfworkbook();
// 第二步,在webbook中新增乙個sheet,對應excel檔案中的sheet
hssfsheet sheet = wb.createsheet("sheet1");
// 第三步,在sheet中新增表頭第0行,注意老版本poi對excel的行數列數有限制short
hssfrow row = sheet.createrow(0);
hssfcell cell = null;
//設定樣式
row.setheight((short) 400);
hssfcellstyle style = wb.createcellstyle();
style.setverticalalignment(hssfcellstyle.vertical_center);//垂直居中
style.setalignment(hssfcellstyle.align_center);//水平居中
//設定字型
hssffont font = wb.createfont();
font.setfontheightinpoints((short) 10);//設定字型大小
font.setboldweight(hssffont.boldweight_bold);//粗體粗細
style.setfont(font);//選擇需要用到的字型格式
//設定列寬
sheet.setcolumnwidth((short) 1, (short) 6500);
sheet.setcolumnwidth((short) 2, (short) 6000);
sheet.setcolumnwidth((short) 3, (short) 6000);
sheet.setcolumnwidth((short) 9, (short) 4500);
sheet.setcolumnwidth((short) 10, (short) 4000);
sheet.setcolumnwidth((short) 11, (short) 4000);
sheet.setcolumnwidth((short) 12, (short) 4000);
sheet.setcolumnwidth((short) 13, (short) 4000);
//設定標題
for(int i=0;ishort) i);
cell.setencoding(hssfcell.encoding_utf_16);
cell.setcellvalue(heard[i]);
}//設定內容
for(int i=0;i1);
row.createcell((short) 0).setcellvalue(xuhao[i]);
row.createcell((short) 1).setcellvalue(gppayfeeinfodtobusinessno[i]);
row.createcell((short) 2).setcellvalue(gppayfeeinfodtopaymentno[i]);
row.createcell((short) 3).setcellvalue(gppayfeeinfodtopolicyno[i]);
cell = row.createcell((short) 4);
cell.setencoding(hssfcell.encoding_utf_16);
cell.setcellvalue("1".equals(gppayfeeinfodtobusinesstype[i])?"投保":"批改申請" );
cell = row.createcell((short) 5);
cell.setencoding(hssfcell.encoding_utf_16);
cell.setcellvalue(gppayfeeinfodtopayeename[i]);
row.createcell((short) 6).setcellvalue(gppayfeeinfodtoriskcode[i]);
row.createcell((short) 7).setcellvalue(gppayfeeinfodtocurrency[i]);
row.createcell((short) 8).setcellvalue(gppayfeeinfodtopayfee[i]);
row.createcell((short) 9).setcellvalue(gppayfeeinfodtopayfeeduedate[i]);
row.createcell((short) 10).setcellvalue(gppayfeeinfodtostartdate[i]);
row.createcell((short) 11).setcellvalue(gppayfeeinfodtounderwriteenddate[i]);
row.createcell((short) 12).setcellvalue(gppayfeeinfodtocompanycode[i]);
row.createcell((short) 13).setcellvalue(gppayfeeinfodtodealercode[i]);
}//初始化流
bytearrayoutputstream os = new bytearrayoutputstream();
bufferedinputstream bis = null;
bufferedoutputstream bos = null;
try
} catch (exception e) finally
}
VC匯出CListCtrl資料到Excel兩種方法
vc匯出clistctrl資料到excel兩種方法 方法1 使用mfc的cdatabase類直接執行sql命令的方式實現 在檔案中包含標頭檔案 include include include void exportlisttoexcel clistctrl plist,cstring celfile...
VC匯出CListCtrl資料到Excel兩種方法
方法1 使用mfc的cdatabase類直接執行sql命令的方式實現 在檔案中包含標頭檔案 include include include void exportlisttoexcel clistctrl plist,cstring celfile cstring ssheetname 建立進行訪問...
使用HTML,CSS快速匯出資料到Excel
在head中加入css定義 mso number format 0 no decimals mso number format 0 000 3 decimals mso number format 0 000 comma with 3 dec mso number format mm dd yy d...