- ByteArrayOutputStream out = new ByteArrayOutputStream();
- String spreadjson = "spreadjs 导出来的样式"
- out.write(spreadjson.getBytes(StandardCharsets.UTF_8));
-
- InputStream excelStream = new ByteArrayInputStream(bytes);
- TempFileCache cache = CacheFactory.getCommonCacheFactory().getTempFileCache();
- byte[] excelBytes = kd.fi.bcm.spread.util.SpreadUtils.fromJson(excelStream);
- String url = cache.saveAsUrl(fileName+".xls",excelBytes,100);//cache到文件服务器
- Workbook workbook = new Workbook();
- workbook.open(cache.getInputStream(url));
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- workbook.save(out, SaveFileFormat.Pdf);
- InputStream fis = null;
- String pdfURL = url;
- fis = new ByteArrayInputStream(out.toByteArray());
- pdfURL = cache.saveAsUrl(fileName+".pdf",fis,100);
复制代码
大致代码就是这样了 |