我是Java的新手,我正在尝试使用tablesaw(https://jtablesaw.github.io/tablesaw/(进行一些数据可视化,但是在导入文件期间我得到了IOException(请参阅下面的代码(。
我已经尝试了表格锯的各种功能和方法(读取/读取多个和XlsxReaderOptions的各种构建器(。xls 导入导出(目前(还没有很好的文档记录,但我试图重用我在 github 中看到的 jUnit 测试。
我还检查了文件路径,java.io.File找到了它。所以我想错误出在下面的代码中。
这里有人使用台锯并且可以向我展示导入/导出 excel 文件的正确方法吗?还是通过另一个数据可视化库?
import tech.tablesaw.api.Table;
import tech.tablesaw.io.xlsx.*;
[...]
public class App
{
[...]
private static Table getTable(String FileName)
{
XlsxReader reader = new XlsxReader();
XlsxReadOptions options = XlsxReadOptions.builder(FileName).build();
Table tab = reader.read(options);
return tab;
}
错误消息 :
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type IOException
at com.testPack.excelRun.App.getTable(App.java:30)
at com.testPack.excelRun.App.main(App.java:22)
感谢您提供的任何帮助!
您可以尝试通过以下导入解决问题:
import java.io.IOException;
并像这样添加IOException
来处理您的潜艇:
private static Table getTable(String FileName)throws IOException{
XlsxReader reader = new XlsxReader();
XlsxReadOptions options = XlsxReadOptions.builder(FileName).build();
Table tab = reader.read(options);
return tab;
}
还要把IOException
放在你的main
里