乙個POI匯出excle示例

2021-04-21 03:53:41 字數 1375 閱讀 7306

www.grn8.com

綠吧導航網 免費廣告換連線。

hssfworkbook wb = new hssfworkbook();

hssfsheet sheet = wb.createsheet("addresslist");

hssfrow row = sheet.createrow(0);

hssfcell cell = row.createcell((short) 0);

cell.setencoding(hssfcell.encoding_utf_16);

cell.setcellvalue("姓名");

cell = row.createcell((short) 1);

cell.setcellvalue("所屬組");

cell = row.createcell((short) 2);

cell.setcellvalue("手機號碼1");

cell = row.createcell((short) 3);

cell.setcellvalue("手機號碼2");

cell = row.createcell((short) 4);

cell.setcellvalue("辦公**");

cell = row.createcell((short) 5);

cell.setcellvalue("住宅**");

useraccountdto uad = (useraccountdto)request.getsession().getattribute("user");

try}

}catch(exception e)

sheet.autosizecolumn(( short ) 0 ); // 調整第一列寬度

sheet.autosizecolumn(( short ) 1 ); // 調整第二列寬度

sheet.autosizecolumn(( short ) 2 ); // 調整第三列寬度

sheet.autosizecolumn(( short ) 3 ); // 調整第四列寬度

sheet.autosizecolumn(( short ) 4 ); // 調整第五列寬度

sheet.autosizecolumn(( short ) 5 ); // 調整第六列寬度

wb.write(response.getoutputstream());

response.getoutputstream().flush();

response.getoutputstream().close();

return null;

}

使用POI匯出Excel示例

使用poi匯出excel,需要的jar包 poi bin 3.9 20121203.zip 示例 如下 import org.apache.poi.hssf.usermodel.hssfcell import org.apache.poi.hssf.usermodel.hssfcellstyle i...

乙個PlaySound示例

using system using system.collections using system.componentmodel using system.runtime.interopservices internal class helpers dllimport winmm public s...

xml的乙個示例

function.h cstring openfile cstring cstring getcontext cstring,int,int void str2array cstring struct xmlnode function.cpp include include include incl...