读取excel生成highcharts速度曲线

https://download.csdn.net/download/qq_31293575/14884249

一、HighCharts简介

 

Highcharts 是一个用纯JS编写的一个图表库,能够很简单便捷的在web网站或是web应用程序添加有交互性的图表,并且免费提供给个人学习、个人网站和非商业用途使用。HighCharts支持的图表类型有曲线图、区域图、柱状图、饼状图、散状点图和综合图表。

二、入门案例

第一步:将Highcharts相关资源文件复制到项目中

 

第二步:在页面中引入相关js文件

 
  1. <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>

  2. <script src="${pageContext.request.contextPath }/js/highcharts/highcharts.js"></script>

  3. <script src="${pageContext.request.contextPath }/js/highcharts/modules/exporting.js"></script>

 

第三步:在页面中提供一个div,并指定id属性

 
  1. <body>

  2. <div id="test"></div>

  3. </body>

 

第四步:调用Highcharts提供的方法,动态创建图表

 
  1. $(function(){

  2. //页面加载完成后,动态创建图表

  3. $("#test").highcharts({

  4. title: {

  5. text: '各浏览器份额'

  6. },

  7. series: [{

  8. type: 'pie',

  9. name: '浏览器占比',

  10. data: [

  11. ['Firefox', 45.0],

  12. ['IE', 26.8],

  13. ['Safari', 8.5],

  14. ['Opera', 6.2],

  15. ['Others', 0.7]

  16. ]

  17. }]

  18. });

  19. });


效果展示

 

package com.liquid.excel.excel;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class IndexController {

    @RequestMapping("/")
    public String getIndex(){
        return "/index";
    }

    @RequestMapping("/getData")
    @ResponseBody
    public List<Object> getData(@RequestParam("rowNum")Integer rowNum) throws Exception{
        List<Object> bankListByExcel = ExcelFormatUtil.getBankListByExcel(rowNum);
        return bankListByExcel;
    }
}
package com.liquid.excel.excel;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.util.ArrayList;
import java.util.List;

public class ExcelFormatUtil {


    /**
     * 读取excel表
     *
     * @param
     * @param
     * @return Workbook work = new XSSFWorkbook("D://GoolgeDownload//Summary.xlsx");
     * @throws Exception
     */
    public static List<Object> getBankListByExcel(int rowNum) throws Exception {
        List<Object> list = new ArrayList<>();             // 读取的数据放入该集合中
        XSSFWorkbook book = new XSSFWorkbook("D:\\dredging_data_a.xlsx");        // 文件所在位置
        XSSFSheet sheet = book.getSheetAt(0);
        XSSFRow row = sheet.getRow(rowNum);
        if (row != null) {
            double name = row.getCell(0).getNumericCellValue();
            list.add(name);
            double b = row.getCell(1).getNumericCellValue();  // 医院名称		// 这边为读取的字段名称 ,写自己的就好
            list.add(b);            // 将读取的数据放入集合
            double c = row.getCell(2).getNumericCellValue();  // 医院名称		// 这边为读取的字段名称 ,写自己的就好
            list.add(c);            // 将读取的数据放入集合
            double d = row.getCell(3).getNumericCellValue();  // 医院名称		// 这边为读取的字段名称 ,写自己的就好
            list.add(d);            // 将读取的数据放入集合
            String e = row.getCell(4).getStringCellValue();  // 医院名称		// 这边为读取的字段名称 ,写自己的就好
            list.add(e);            // 将读取的数据放入集合
        }
        return list;
    }
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

全职计算机毕业设计

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值