excelStream我正在尝试下载一个 excel 文件。
在我的行动课上
public class ActivityTrackerExlReportAction extends BaseAction
{
private InputStream excelStream;
private UserMasterDTO userMasterDTO;
public InputStream getExcelStream()
{
return excelStream;
}
public void setExcelStream(InputStream excelStream) {
this.excelStream = excelStream;
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
WorkbookSettings wbSettings = new WorkbookSettings();
try
{
response.setHeader("Content-Disposition", "attachment; filename=/timesheet.xls");
wbSettings.setLocale(new Locale("en", "EN"));
WritableWorkbook workbook = Workbook.createWorkbook(outputStream, wbSettings);
workbook.createSheet("Report", 0);
WritableSheet excelSheet = workbook.getSheet(0);
service.createLabel(excelSheet);
service.createContent(excelSheet);
workbook.write();
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
setExcelStream(inputStream);
workbook.close();
outStream.flush();
outStream.close();
}
catch(Exception e)
{
}
finally
{
// outStream.close();
}
return "generateReport
}
我的struts.xml
包含:
<result type="stream" name="generateReport">
<param name="contentType">"application/vnd.ms-excel"</param>
<param name="inputName">excelStream</param>
<param name="bufferSize">1024</param>
</result>
我正在使用JXL
创建和编写 Excel 工作表。为什么我会收到错误以及如何摆脱它?在调用堆栈中找不到java.io.InputStream
具有该名称的[excelStream]
我的是 Stacktraces:
java.lang.IllegalArgumentException:在调用堆栈中找不到名称为 [excelStream] 的 java.io.InputStream。检查为此操作指定的标记。
org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:237)
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186) ......