我使用JSF 1.1在Tomcat 6.0.26和Java 1.4版本。我必須在我的項目中使用它們。我的jsf頁面有一個數據表,我希望他們導出,但保存爲框。點擊export excel commandlink後顯示如下瀏覽器:JSF 1.1另存爲對話框問題
С±;;þÿþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootEntryÿÿÿÿÿÿÿÿ@Workbookÿÿÿÿÿÿÿÿÿÿÿÿ0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿOIAA°AA \ pmusty乙°的=œ¯¼= H \:δH#8X @ 「·Ú1ÈÿArial1ÈÿArial1ÈÿArial1ÈÿArial」 $ 「#,## 0 _);(」 $ 「#,## 0)!」 $ 「#,## 0 _); [紅色](」 $ 「#,## 0)」, 「$」 #,## 0.00 _);( 「$」 #,## 0.00)' 「」 $「# ,## 0.00 _); [Red](「$」#,## 0.00)7 * 2 _(「$」*#,## 0 _); _(「$」*(#,## 0); _ (「$」*「 - 」);(@)))(*#,## 0 _); _(*(#,## 0); _(* 「 - 」 );(@):?(「$ 「*#,## 0.00 _); _(」 $ 「*(#,## 0.00); _(」 $「* 」 - 「 ?? );(@)6 + 1(*# ,## 0.00 _); _(*(#,## 0.00); _(*「 - 」?? );(@_)àõÿààõÿàÀàõÿàààààààààààààààààààààà AOY OA AOY OA AOY OA AOY OA AOY OA AOY OA AOY OA A A A + OY OA A)OY OAà,OY OA A * OY OAàOY OA「€Y「€Y「€Y「€Y「€ÿ 「......“Sheet0Œü¿ADSOYADDEPARTMANEVCEPDAHILIerdemaktasYonetici02mesutozenIT03mustafaaydemirNetweaver01yunustastutanDeneme0506004ÿT'IΆ»dü©ñÒMbP ?_ * +,€%ÿÁƒ「¡「d ,,à?à?UY是是是是是是是是是是是是是是是是是是是是是是是是是是是是是YYYYY> ¶@ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ!「#$þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
我該如何解決這個問題?
日Thnx balusC。但問題沒有解決。這裏是我的代碼..
'公共字符串出口(名單列表){
Iterator i1 = list.iterator();
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();
HSSFRow r = null;
HSSFCell c = null;
int i = 0;
try {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
HttpServletResponse resp = (HttpServletResponse) externalContext
.getResponse();
ServletOutputStream out = resp.getOutputStream();
resp.setContentType("application/vnd.ms-excel");
HSSFRow r2 = s.createRow(0);
for (short cellnum = (short) 0; cellnum < 6; cellnum++) {
c = r2.createCell(cellnum);
if (cellnum == 0)
c.setCellValue("AD");
else if (cellnum == 1)
c.setCellValue("SOYAD");
else if (cellnum == 2)
c.setCellValue("DEPARTMAN");
else if (cellnum == 3)
c.setCellValue("EV");
else if (cellnum == 4)
c.setCellValue("CEP");
else if (cellnum == 5)
c.setCellValue("DAHILI");
}
while (i1.hasNext()) {
md1 = new Model();
md1 = (Model) i1.next();
int rownum = i + 1;
r2 = s.createRow(rownum);
for (short cellnum = (short) 0; cellnum < 6; cellnum++) {
c = r2.createCell(cellnum);
if (cellnum == 0)
c.setCellValue(md1.getAd());
else if (cellnum == 1)
c.setCellValue(md1.getSoyad());
else if (cellnum == 2)
c.setCellValue(md1.getDepartman());
else if (cellnum == 3)
c.setCellValue(md1.getEv());
else if (cellnum == 4)
c.setCellValue(md1.getCep());
else if (cellnum == 5)
c.setCellValue(md1.getDahili());
}
i++;
}
resp.setHeader("content-disposition:",
"attachment; filename= \"TelefonRehberi.xls\"");
wb.write(out);
out.flush();
out.close();
facesContext.responseComplete();
} catch (Exception e) {
System.out.println("Error: " + e);
}
return "";
}`
你的JSF源代碼是什麼樣的? –