Paul Calhoun이 내가 원하는 스프레드 시트를 만들기 위해 마사지 한 샘플 코드를 보냈습니다. 내가하지 못했던 일이 무엇인지 모르겠지만, 지금은 이것이 솔루션의 핵심이라고 생각합니다. FileOutputStream 또는 ByteArrayOutputStream 대신 OutputStream을 사용하는 것만으로도 충분합니다. 누군가 다른 사람이 묻는 시간, 희망,이 문제가 발생하고있는 경우
// The Faces Context global object provides access to the servlet environment via the external content
var extCont = facesContext.getExternalContext();
// The servlet's response object provides control to the response object
var pageResponse = extCont.getResponse();
//Get the output stream to stream binary data
var pageOutput = pageResponse.getOutputStream();
// Set the content type and headers
pageResponse.setContentType("application/x-ms-excel");
pageResponse.setHeader("Cache-Control", "no-cache");
pageResponse.setHeader("Content-Disposition","inline; filename=" + fileName);
//Write the output, flush the buffer and close the stream
wb.write(pageOutput);
pageOutput.flush();
pageOutput.close();
// Terminate the request processing lifecycle.
facesContext.responseComplete();
나는 기꺼이 도움을 제공 할 것입니다, 나는
당이 옳다 .... 일이 다른 무엇을 더 이해할 것이다. OpenNTF의 XSnippets에서 XAgent 스 니펫을 살펴보십시오. 출력 스트림을 제공합니다. 따라서 자신의 스트림을 만드는 대신 메서드에 매개 변수로 전달하십시오. 그러면 content-disposition 헤더가 파일 이름을 결정할 수 있습니다. 사용자가 저장을 확인해야한다는 점에 유의하십시오. 또한 고급 Excel 출력 기능을위한 Apache POI를 살펴보십시오. – stwissel
감사합니다. Per. @stwissel Apache POI를 사용하고 있지만, Russ Maher의 구현을 취한 상태에서 조금이라도 확장 한 실제 아마추어입니다. –