org.springframework.web.servlet.view.document

Class AbstractXlsView

    • Constructor Detail

      • AbstractXlsView

        public AbstractXlsView()
        Default Constructor. Sets the content type of the view to "application/vnd.ms-excel".
    • Method Detail

      • renderMergedOutputModel

        protected final void renderMergedOutputModel(java.util.Map<java.lang.String,java.lang.Object> model,
                                                     HttpServletRequest request,
                                                     HttpServletResponse response)
                                              throws java.lang.Exception
        Renders the Excel view, given the specified model.
        Specified by:
        renderMergedOutputModel in class AbstractView
        Parameters:
        model - combined output Map (never null), with dynamic values taking precedence over static attributes
        request - current HTTP request
        response - current HTTP response
        Throws:
        java.lang.Exception - if rendering failed
      • createWorkbook

        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.

        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.

        Parameters:
        model - the model Map
        request - current HTTP request (for taking the URL or headers into account)
        Returns:
        the new Workbook instance
      • renderWorkbook

        protected void renderWorkbook(org.apache.poi.ss.usermodel.Workbook workbook,
                                      HttpServletResponse response)
                               throws java.io.IOException
        The actual render step: taking the POI Workbook and rendering it to the given response.
        Parameters:
        workbook - the POI Workbook to render
        response - current HTTP response
        Throws:
        java.io.IOException - when thrown by I/O methods that we're delegating to
      • buildExcelDocument

        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)
                                            throws java.lang.Exception
        Application-provided subclasses must implement this method to populate the Excel workbook document, given the model.
        Parameters:
        model - the model Map
        workbook - the Excel workbook to populate
        request - in case we need locale etc. Shouldn't look at attributes.
        response - in case we need to set cookies. Shouldn't write to it.
        Throws:
        java.lang.Exception