system.out.println("年: " + year);
cellrangeaddress cellrangeaddress=new cellrangeaddress(0,0,0,10);
listlist = new arraylist();
string querygrade=request.getparameter("querygrade");
string queryprocode=request.getparameter("queryprocode");
string queryclasscode=request.getparameter("queryclasscode");
string name="";
if(request.getparameter("name")!=null)
/*system.out.println("輸出-----------------");
system.out.println(querygrade);
system.out.println(queryprocode);
system.out.println(queryclasscode);
system.out.println(name);
*/pd1.put("querygrade", querygrade);
pd1.put("queryprocode", queryprocode);
pd1.put("queryclasscode", queryclasscode);
pd1.put("name", name);
list=infoservice.getinfoexcel(pd1);
system.out.println("****************************");
system.out.println(list.tostring());
system.out.println("****************************");
hssfworkbook wb = new hssfworkbook();
// 設定表單的居中格式
hssfcellstyle style = wb.createcellstyle();
style.setalignment(hssfcellstyle.align_center);//水平居中
style.setverticalalignment(hssfcellstyle.vertical_center);//垂直居中
//字型
hssffont font=wb.createfont();
font.setboldweight(hssffont.boldweight_bold);
font.setfontheightinpoints((short)10);
style.setfont(font);
hssfcellstyle style1 = wb.createcellstyle();
style1.setalignment(hssfcellstyle.align_center);//水平居中
style1.setverticalalignment(hssfcellstyle.vertical_center);//垂直居中
//字型
hssffont font1=wb.createfont();
font1.setboldweight(hssffont.boldweight_bold);
font1.setfontheightinpoints((short)16);
style1.setfont(font1);
// 然後就是開始建立表頭,還有表中的資料
// 宣告exceln表名
hssfsheet sheet = wb.createsheet(year+"畢業生畢業**題目彙總表");
// 然後在表明中建立第一行
sheet.addmergedregion(cellrangeaddress);
/*response.setcharacterencoding("utf-8");*/
/*response.setheader("content-disposition", "attachment;filename="+filename+".xls");*/
response.setheader("content-disposition", "attachment;filename="+new string((year+"屆本科畢業生**(設計)選題彙總表"+".xls").getbytes(),"iso-8859-1"));
hssfrow row1=sheet.createrow(0);
hssfcell cell1=row1.createcell(0);
cell1.setcellstyle(style1);
cell1.setcellvalue(year+"年畢業生畢業**題目彙總表");
hssfrow row = sheet.createrow(1);// 首先在建立第一行
string title=;
hssfcell cell = row.createcell(1);
for(int i=0;icell = row.createcell(i);
cell.setcellvalue(title[i]);
cell.setcellstyle(style);
}//設定第一列的寬度是15個字元寬度
sheet.setcolumnwidth(0, 18 * 256);
sheet.setcolumnwidth(1, 25 * 256);
sheet.setcolumnwidth(3, 35 * 256);
sheet.setcolumnwidth(4, 14 * 256);
sheet.setcolumnwidth(5, 35 * 256);
sheet.setcolumnwidth(7, 14 * 256);
sheet.setcolumnwidth(8, 10 * 256);
sheet.setcolumnwidth(9, 10 * 256);
sheet.setcolumnwidth(10, 20 * 256);
for (int i = 0; i < list.size(); i++)
else
row.createcell(7).setcellvalue(pd.getstring("name"));
row.createcell(8).setcellvalue(pd.getstring("highesteducation"));
row.createcell(9).setcellvalue(pd.getstring("title"));
if(pd.getstring("isoutside").equals("true"))
else
/*if(pd.getstring("isoutside")=="0")*/
"isoutside"));
}servletoutputstream out = response.getoutputstream();
wb.write(out);
out.close();
}
關於sqlsever 匯出檔案
這裡使用xp cmdshell命令。mark一下。注 如果操作sql server的使用者沒有sp configure的使用許可權,需要將對應使用者新增 sysadmin 角色。1 開啟 xp cmdshell 命令,方法如下 推薦此方法,因為在任何版本的sql server中都可以使用。通過查詢分...
水晶報表匯出檔案的格式設定
原文 水晶報表匯出檔案的格式設定 水晶報表中自帶的匯出和列印功能用起來確實很方便,只不過有時候需要匯出的檔案並不需要那麼多種型別,在網上找到一些朋友的 總結了一下,可以通過 實現自定義匯出檔案型別 首先需要定義乙個列舉 public enum allowedexportformat 然後就可以設定水...
將控制項內容匯出為Excel檔案
經常在網頁中,我們需要將乙個控制項 典型的例子是gridview這種 控制項 的內容匯出到excel。大致如下 public static void toexcel control control,string filename 需要注意的乙個問題是,經常會遇到乙個錯誤 型別gridview的控制項...