品牌网站方案,ui设计界面效果图,句容市建设局网站,为什么装修公司建议半包目录 Apache ECharts 介绍
入门
绘制一个简单的图表
Apache POI 介绍
通过POI创建Excel文件并且写入文件内容
通过POI读取Excel文件中的内容
导出Excel表格 Apache ECharts 介绍
Apache ECharts 是一款基于 Javascript 的数据可视化图表库#xff0c;提供直观#xf…目录 Apache ECharts 介绍
入门
绘制一个简单的图表
Apache POI 介绍
通过POI创建Excel文件并且写入文件内容
通过POI读取Excel文件中的内容
导出Excel表格 Apache ECharts 介绍
Apache ECharts 是一款基于 Javascript 的数据可视化图表库提供直观生动可交互可个性化定制的数据可视化图表。
官网地址Apache ECharts
入门
在 echarts CDN by jsDelivr - A CDN for npm and GitHub 选择 dist/echarts.js点击并保存为 echarts.js 文件。
在刚才保存 echarts.js 的目录新建一个 index.html 文件内容如下
!DOCTYPE html
htmlheadmeta charsetutf-8 /!-- 引入刚刚下载的 ECharts 文件 --script srcecharts.js/script/head
/html
绘制一个简单的图表
完整代码如下
!DOCTYPE html
htmlheadmeta charsetutf-8 /titleECharts/title!-- 引入刚刚下载的 ECharts 文件 --script srcecharts.js/script/headbody!-- 为 ECharts 准备一个定义了宽高的 DOM --div idmain stylewidth: 600px;height:400px;/divscript typetext/javascript// 基于准备好的dom初始化echarts实例var myChart echarts.init(document.getElementById(main));// 指定图表的配置项和数据var option {title: {text: ECharts 入门示例},tooltip: {},legend: {data: [销量]},xAxis: {data: [衬衫, 羊毛衫, 雪纺衫, 裤子, 高跟鞋, 袜子]},yAxis: {},series: [{name: 销量,type: bar,data: [5, 20, 36, 10, 10, 20]}]};// 使用刚指定的配置项和数据显示图表。myChart.setOption(option);/script/body
/html
总结使用Echarts重点在于研究当前图表所需的数据格式。通常是需要后端提供符合格式要求的动态数据然后响应给前端来展示图表。
Apache POI 介绍
Apache POI 是一个处理Miscrosoft Office各种文件格式的开源项目。简单来说就是我们可以使用 POI 在 Java 程序中对Miscrosoft Office各种文件进行读写操作。
一般情况下POI 都是用于操作 Excel 文件。
Apache POI 的应用场景
• 银行网银系统导出交易明细 • 各种业务系统导出 Excel 报表 • 批量导入业务数据 通过POI创建Excel文件并且写入文件内容 通过POI读取Excel文件中的内容 导出Excel表格 /*** 导出运营数据报表* param response*/Overridepublic void exportBusinessData(HttpServletResponse response) {//1.查询数据库 获取营业数据LocalDate dateBegin LocalDate.now().minusDays(30);LocalDate dateEnd LocalDate.now().minusDays(1);BusinessDataVO businessDataVO workspaceService.getBusinessData(LocalDateTime.of(dateBegin, LocalTime.MIN), LocalDateTime.of(dateEnd, LocalTime.MAX));//2.通过POI将数据写入到Excel文件中InputStream in this.getClass().getClassLoader().getResourceAsStream(templete/运营数据报表模板);try {//基于模板文件创建一个新的Excel文件XSSFWorkbook excel new XSSFWorkbook(in);//获取标签页XSSFSheet sheet excel.getSheet(Sheet1);//填充数据--时间sheet.getRow(1).getCell(1).setCellValue(时间 dateBegin 至 dateEnd);XSSFRow row sheet.getRow(3);row.getCell(2).setCellValue(businessDataVO.getTurnover());row.getCell(4).setCellValue(businessDataVO.getOrderCompletionRate());row.getCell(6).setCellValue(businessDataVO.getNewUsers());row sheet.getRow(4);row.getCell(2).setCellValue(businessDataVO.getValidOrderCount());row.getCell(4).setCellValue(businessDataVO.getUnitPrice());//填充明细数据for(int i 0;i30;i){LocalDate date dateBegin.plusDays(1);//查询某一天的营业数据BusinessDataVO businessData workspaceService.getBusinessData(LocalDateTime.of(date, LocalTime.MIN), LocalDateTime.of(date, LocalTime.MAX));//获得某一行row sheet.getRow(7i);row.getCell(1).setCellValue(date.toString());row.getCell(2).setCellValue(businessData.getTurnover());row.getCell(3).setCellValue(businessData.getValidOrderCount());row.getCell(4).setCellValue(businessData.getOrderCompletionRate());row.getCell(5).setCellValue(businessData.getUnitPrice());row.getCell(6).setCellValue(businessData.getNewUsers());}//通过输出流将Excel文件下载到客户端浏览器ServletOutputStream out response.getOutputStream();excel.write(out);//关闭资源out.close();excel.close();} catch (IOException e) {throw new RuntimeException(e);}}