public abstract class AbstractXlsView extends AbstractView
For working with the workbook in the subclass, see Apache's POI site
DEFAULT_CONTENT_TYPE
logger
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
Constructor and Description |
---|
AbstractXlsView()
Default Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
buildExcelDocument(java.util.Map<java.lang.String,java.lang.Object> model,
org.apache.poi.ss.usermodel.Workbook workbook,
HttpServletRequest request,
HttpServletResponse response)
Application-provided subclasses must implement this method to populate
the Excel workbook document, given the model.
|
protected org.apache.poi.ss.usermodel.Workbook |
createWorkbook(java.util.Map<java.lang.String,java.lang.Object> model,
HttpServletRequest request)
Template method for creating the POI
Workbook instance. |
protected boolean |
generatesDownloadContent()
Return whether this view generates download content
(typically binary content like PDF or Excel files).
|
protected void |
renderMergedOutputModel(java.util.Map<java.lang.String,java.lang.Object> model,
HttpServletRequest request,
HttpServletResponse response)
Renders the Excel view, given the specified model.
|
protected void |
renderWorkbook(org.apache.poi.ss.usermodel.Workbook workbook,
HttpServletResponse response)
The actual render step: taking the POI
Workbook and rendering
it to the given response. |
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, toString, writeToResponse
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
public AbstractXlsView()
protected boolean generatesDownloadContent()
AbstractView
The default implementation returns false
. Subclasses are
encouraged to return true
here if they know that they are
generating download content that requires temporary caching on the
client side, typically via the response OutputStream.
protected final void renderMergedOutputModel(java.util.Map<java.lang.String,java.lang.Object> model, HttpServletRequest request, HttpServletResponse response) throws java.lang.Exception
renderMergedOutputModel
in class AbstractView
model
- combined output Map (never null
),
with dynamic values taking precedence over static attributesrequest
- current HTTP requestresponse
- current HTTP responsejava.lang.Exception
- if rendering failedprotected org.apache.poi.ss.usermodel.Workbook createWorkbook(java.util.Map<java.lang.String,java.lang.Object> model, HttpServletRequest request)
Workbook
instance.
The default implementation creates a traditional HSSFWorkbook
.
Spring-provided subclasses are overriding this for the OOXML-based variants;
custom subclasses may override this for reading a workbook from a file.
model
- the model Maprequest
- current HTTP request (for taking the URL or headers into account)Workbook
instanceprotected void renderWorkbook(org.apache.poi.ss.usermodel.Workbook workbook, HttpServletResponse response) throws java.io.IOException
Workbook
and rendering
it to the given response.workbook
- the POI Workbook to renderresponse
- current HTTP responsejava.io.IOException
- when thrown by I/O methods that we're delegating toprotected abstract void buildExcelDocument(java.util.Map<java.lang.String,java.lang.Object> model, org.apache.poi.ss.usermodel.Workbook workbook, HttpServletRequest request, HttpServletResponse response) throws java.lang.Exception
model
- the model Mapworkbook
- the Excel workbook to populaterequest
- in case we need locale etc. Shouldn't look at attributes.response
- in case we need to set cookies. Shouldn't write to it.java.lang.Exception