Excel 的Html预览
Excel预览,这里支持了比较简单的预览,样式也都可以转换过去,支持03 和 更高版本 使用也是简单的很ExcelXorHtmlUtil.excelToHtml(params),也支持图片的预览,demo如下
/**
* 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());
}
返回一个string的html界面,输出到前台就可以了