public class ExcelView
extends org.springframework.web.servlet.view.document.AbstractXlsxStreamingView
限定符和类型 | 字段和说明 |
---|---|
private java.util.function.Consumer<org.apache.poi.ss.usermodel.Workbook> |
consumer |
private java.lang.String |
filename |
static java.lang.String |
SUFFIX |
构造器和说明 |
---|
ExcelView(java.util.function.Consumer<org.apache.poi.ss.usermodel.Workbook> consumer) |
ExcelView(java.lang.String filename,
java.util.function.Consumer<org.apache.poi.ss.usermodel.Workbook> consumer)
@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 void |
buildExcelDocument(java.util.Map<java.lang.String,java.lang.Object> model,
org.apache.poi.ss.usermodel.Workbook workbook,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
java.lang.String |
getFilename() |
void |
setFilename(java.lang.String filename) |
createWorkbook, renderWorkbook
generatesDownloadContent, renderMergedOutputModel
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
private java.util.function.Consumer<org.apache.poi.ss.usermodel.Workbook> consumer
private java.lang.String filename
public static final java.lang.String SUFFIX
public ExcelView(java.lang.String filename, java.util.function.Consumer<org.apache.poi.ss.usermodel.Workbook> consumer)
@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 setpublic ExcelView(java.util.function.Consumer<org.apache.poi.ss.usermodel.Workbook> consumer)
protected void buildExcelDocument(java.util.Map<java.lang.String,java.lang.Object> model, org.apache.poi.ss.usermodel.Workbook workbook, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
buildExcelDocument
在类中 org.springframework.web.servlet.view.document.AbstractXlsView
java.lang.Exception
public java.lang.String getFilename()
public void setFilename(java.lang.String filename)
filename
- the filename to set