Save This Page
Home » spring-framework-2.5.4 » org.springframework » web » servlet » view » document » [javadoc | source]
org.springframework.web.servlet.view.document
abstract public class: AbstractJExcelView [javadoc | source]
java.lang.Object
   org.springframework.context.support.ApplicationObjectSupport
      org.springframework.web.context.support.WebApplicationObjectSupport
         org.springframework.web.servlet.view.AbstractView
            org.springframework.web.servlet.view.document.AbstractJExcelView

All Implemented Interfaces:
    View, BeanNameAware, ServletContextAware, ApplicationContextAware

Convenient superclass for Excel document views.

This class uses the JExcelAPI instead of POI. More information on JExcelAPI can be found on their website.

Properties:

The file will be searched with locations in the following order:

For working with the workbook in the subclass, see Java Excel API site

As an example, you can try this snippet:

protected void buildExcelDocument(Map model, WritableWorkbook workbook, HttpServletRequest request,
HttpServletResponse response) {
if (workbook.getNumberOfSheets() == 0) {
workbook.createSheet("Spring", 0);
}

WritableSheet sheet = workbook.getSheet("Spring");
Label label = new Label(0, 0, "This is a nice label");
sheet.addCell(label);
}
The use of this view is close to the AbstractExcelView class, just using the JExcel API instead of the Apache POI API.
Fields inherited from org.springframework.web.servlet.view.AbstractView:
DEFAULT_CONTENT_TYPE
Fields inherited from org.springframework.context.support.ApplicationObjectSupport:
logger
Constructor:
 public AbstractJExcelView() 
Method from org.springframework.web.servlet.view.document.AbstractJExcelView Summary:
buildExcelDocument,   generatesDownloadContent,   getTemplateSource,   renderMergedOutputModel,   setUrl
Methods from org.springframework.web.servlet.view.AbstractView:
addStaticAttribute,   createRequestContext,   exposeModelAsRequestAttributes,   generatesDownloadContent,   getAttributesMap,   getBeanName,   getContentType,   getRequestContextAttribute,   getStaticAttributes,   prepareResponse,   render,   renderMergedOutputModel,   setAttributes,   setAttributesCSV,   setAttributesMap,   setBeanName,   setContentType,   setRequestContextAttribute,   toString
Methods from org.springframework.web.context.support.WebApplicationObjectSupport:
getServletContext,   getTempDir,   getWebApplicationContext,   initApplicationContext,   initServletContext,   isContextRequired,   setServletContext
Methods from org.springframework.context.support.ApplicationObjectSupport:
getApplicationContext,   getMessageSourceAccessor,   initApplicationContext,   initApplicationContext,   isContextRequired,   requiredContextClass,   setApplicationContext
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.web.servlet.view.document.AbstractJExcelView Detail:
 abstract protected  void buildExcelDocument(Map model,
    WritableWorkbook workbook,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception
    Subclasses must implement this method to create an Excel Workbook document, given the model.
 protected boolean generatesDownloadContent() 
 protected Workbook getTemplateSource(String url,
    HttpServletRequest request) throws Exception 
    Create the workbook from an existing XLS document.
 protected final  void renderMergedOutputModel(Map model,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception 
    Renders the Excel view, given the specified model.
 public  void setUrl(String url) 
    Set the URL of the Excel workbook source, without localization part nor extension.