import java.io.InputStream;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/**
* public class BaseAction extends ActionSupport
* implements ServletRequestAware,ServletResponseAware{}
*/
public class ExportAction extends BaseAction {
private static final longserialVersionUID= 8288703553558391122L;
private InputStream inputStream;
private String fileName; //设置下载文件名
@Override
public String execute() {
Workbook workBook = new HSSFWorkbook();
Sheet sheet = workBook.createSheet("示例报表");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
workBook.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
}
fileName = "FILE.xls";
inputStream = new ByteArrayInputStream(outputStream.toByteArray());
return SUCCESS;
}
public String getFileName(){
return fileName;
}
public InputStream getInputStream(){
return inputStream;
}
public void setInputStream(InputStream inputStream){
this.inputStream=inputStream;
}
}