怎么用java实现读取excel表格里的数据生成曲线图

小边 发布于 2015/01/20 18:46
阅读 4K+
收藏 0
请教各位大神,怎么用java实现读取excel表格里的数据生成曲线图。能提供下思路,及解决方案吗?万分感谢
加载中
0
91porn
91porn

POI读取数据

再通过echarts绘制曲线

http://www.oschina.net/p/echarts-java

0
小边
小边

你好 我用poi 读取数据是:

XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream("D:/TA/Weeky.xlsx")); 

创建对象就报错了:

Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory;
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45)
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:87)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:272)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:258)
at com.code.jtlAnalyzeExcel.AnalyzeExcel.main(AnalyzeExcel.java:17)

0
91porn
91porn

引用来自“小边”的评论

你好 我用poi 读取数据是:

XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream("D:/TA/Weeky.xlsx")); 

创建对象就报错了:

Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory;
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45)
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:87)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:272)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:258)
at com.code.jtlAnalyzeExcel.AnalyzeExcel.main(AnalyzeExcel.java:17)

XSSFWorkbook wb = new XSSFWorkbook("D:/TA/Weeky.xlsx"); 
0
小边
小边

引用来自“小边”的评论

你好 我用poi 读取数据是:

XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream("D:/TA/Weeky.xlsx")); 

创建对象就报错了:

Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory;
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45)
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:87)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:272)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:258)
at com.code.jtlAnalyzeExcel.AnalyzeExcel.main(AnalyzeExcel.java:17)

引用来自“Windows10”的评论

XSSFWorkbook wb = new XSSFWorkbook("D:/TA/Weeky.xlsx"); 
public class AnalyzeExcel {
    public static void main(String args[]) throws FileNotFoundException, IOException {
        XSSFWorkbook wb = new XSSFWorkbook("D:/TA/Weeky.xlsx");  
        XSSFSheet sheet = wb.getSheetAt(0);
        int totalRows = sheet.getLastRowNum();
        for (int i=0; i<=totalRows; i++) {
            XSSFRow row = sheet.getRow(i);
            System.out.println(row.getCell(1).toString()
                    );
        }

        
    }

}

还是报同样的错误


0
午吃好任务
午吃好任务

为什么是excel,不能是excel另存为逗号分割的cvs呢?这样导入数据库后,处理起来更快

0
小边
小边

引用来自“小边”的评论

你好 我用poi 读取数据是:

XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream("D:/TA/Weeky.xlsx")); 

创建对象就报错了:

Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory;
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45)
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:87)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:272)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:258)
at com.code.jtlAnalyzeExcel.AnalyzeExcel.main(AnalyzeExcel.java:17)

引用来自“Windows10”的评论

XSSFWorkbook wb = new XSSFWorkbook("D:/TA/Weeky.xlsx"); 
谢谢! 已经解决,换个1.7的jdk 就可以了!
返回顶部
顶部