类 ExcelView
java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.view.AbstractView
com.publiccms.common.view.ExcelView
- 所有已实现的接口:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.context.ApplicationContextAware,org.springframework.web.context.ServletContextAware,org.springframework.web.servlet.View
public class ExcelView
extends org.springframework.web.servlet.view.AbstractView
-
字段概要
字段修饰符和类型字段说明private Consumer<org.apache.poi.ss.usermodel.Workbook>private Stringstatic final String从类继承的字段 org.springframework.web.servlet.view.AbstractView
DEFAULT_CONTENT_TYPE从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger从接口继承的字段 org.springframework.web.servlet.View
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE -
构造器概要
构造器构造器说明@RequestMapping("export") public ExcelView export() { ExcelView view = new ExcelView(workbook -> { Sheet sheet = workbook.createSheet("sheetname"); int i = 0, j = 0; Row row = sheet.createRow(i++); row.createCell(j++).setCellValue("id"); row.createCell(j++).setCellValue("title"); row = sheet.createRow(i++); row.createCell(j++).setCellValue("id"); row.createCell(j++).setCellValue("title"); }); view.setFilename("filename"); return view; } -
方法概要
修饰符和类型方法说明protected voidbuildExcelDocument(Map<String, Object> model, org.apache.poi.ss.usermodel.Workbook workbook, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) protected org.apache.poi.xssf.streaming.SXSSFWorkbookcreateWorkbook(Map<String, Object> model, jakarta.servlet.http.HttpServletRequest request) This implementation creates aSXSSFWorkbookfor streaming the XLSX format.protected booleanprotected final voidrenderMergedOutputModel(Map<String, Object> model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Renders the Excel view, given the specified model.protected voidrenderWorkbook(org.apache.poi.ss.usermodel.Workbook workbook, jakarta.servlet.http.HttpServletResponse response) The actual render step: taking the POIWorkbookand rendering it to the given response.voidsetFilename(String filename) 从类继承的方法 org.springframework.web.servlet.view.AbstractView
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从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
-
字段详细资料
-
consumer
-
filename
-
SUFFIX
- 另请参阅:
-
-
构造器详细资料
-
ExcelView
@RequestMapping("export") public ExcelView export() { ExcelView view = new ExcelView(workbook -> { Sheet sheet = workbook.createSheet("sheetname"); int i = 0, j = 0; Row row = sheet.createRow(i++); row.createCell(j++).setCellValue("id"); row.createCell(j++).setCellValue("title"); row = sheet.createRow(i++); row.createCell(j++).setCellValue("id"); row.createCell(j++).setCellValue("title"); }); view.setFilename("filename"); return view; }- 参数:
filename-consumer- the consumer to set
-
ExcelView
-
-
方法详细资料
-
generatesDownloadContent
protected boolean generatesDownloadContent()- 覆盖:
generatesDownloadContent在类中org.springframework.web.servlet.view.AbstractView
-
renderMergedOutputModel
protected final void renderMergedOutputModel(Map<String, Object> model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws ExceptionRenders the Excel view, given the specified model.- 指定者:
renderMergedOutputModel在类中org.springframework.web.servlet.view.AbstractView- 抛出:
Exception
-
renderWorkbook
protected void renderWorkbook(org.apache.poi.ss.usermodel.Workbook workbook, jakarta.servlet.http.HttpServletResponse response) throws IOException The actual render step: taking the POIWorkbookand rendering it to the given response.- 参数:
workbook- the POI Workbook to renderresponse- current HTTP response- 抛出:
IOException- when thrown by I/O methods that we're delegating to
-
createWorkbook
protected org.apache.poi.xssf.streaming.SXSSFWorkbook createWorkbook(Map<String, Object> model, jakarta.servlet.http.HttpServletRequest request) This implementation creates aSXSSFWorkbookfor streaming the XLSX format. -
buildExcelDocument
protected void buildExcelDocument(Map<String, Object> model, org.apache.poi.ss.usermodel.Workbook workbook, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws Exception- 抛出:
Exception
-
getFilename
- 返回:
- the filename
-
setFilename
- 参数:
filename- the filename to set
-