Excel2HtmlControllrer.java
2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.bckefu.controller;
import com.bckefu.excel.cache.manager.POICacheManager;
import com.bckefu.excel.entity.ExcelToHtmlParams;
import com.bckefu.excel.util.ExcelXorHtmlUtil;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author : caoliang
* @date : 2017/11/20 下午2:38
*/
@RestController
@RequestMapping("html")
public class Excel2HtmlControllrer {
/**
* 03 版本EXCEL预览
*/
@RequestMapping("03")
public void toHtmlOf03Base(HttpServletResponse response) throws IOException, InvalidFormatException {
ExcelToHtmlParams params = new ExcelToHtmlParams(WorkbookFactory.create(POICacheManager.getFile("exceltohtml/testExportTitleExcel.xls")));
response.getOutputStream().write(ExcelXorHtmlUtil.excelToHtml(params).getBytes());
}
/**
* 07 版本EXCEL预览
*/
@RequestMapping("07")
public void toHtmlOf07Base(HttpServletResponse response) throws IOException, InvalidFormatException {
ExcelToHtmlParams params = new ExcelToHtmlParams(WorkbookFactory.create(POICacheManager.getFile("exceltohtml/testExportTitleExcel.xlsx")));
response.getOutputStream().write(ExcelXorHtmlUtil.excelToHtml(params).getBytes());
}
/**
* 03 版本EXCEL预览
*/
@RequestMapping("03img")
public void toHtmlOf03Img(HttpServletResponse response) throws IOException, InvalidFormatException {
ExcelToHtmlParams params = new ExcelToHtmlParams(WorkbookFactory.create(POICacheManager.getFile("exceltohtml/exporttemp_img.xls")),true,"yes");
response.getOutputStream().write(ExcelXorHtmlUtil.excelToHtml(params).getBytes());
}
/**
* 07 版本EXCEL预览
*/
@RequestMapping("07img")
public void toHtmlOf07Img(HttpServletResponse response) throws IOException, InvalidFormatException {
ExcelToHtmlParams params = new ExcelToHtmlParams(WorkbookFactory.create(POICacheManager.getFile("exceltohtml/exportTemp_image.xlsx")),true,"yes");
response.getOutputStream().write(ExcelXorHtmlUtil.excelToHtml(params).getBytes());
}
}