为了账号安全,请及时绑定邮箱和手机立即绑定

如何将xls文件读入jtable

如何将xls文件读入jtable

慕工程0101907 2021-06-22 14:06:36
我在将 XLS 数据导入 jtable 时遇到问题。我的程序只读取 XLS 的最后一行。这是我的代码:JButton btnImportExcelFiles = new JButton("EXCEL FILES");btnImportExcelFiles.setIcon(new ImageIcon(racunariAplikacija.class.getResource("/image/Excel-icon.png")));btnImportExcelFiles.addActionListener(new ActionListener(){    public void actionPerformed(ActionEvent arg0)    {        FileFilter filter = new FileNameExtensionFilter("Excel Files", "xls");        // here is my file chooser        JFileChooser jf = new JFileChooser();        jf.addChoosableFileFilter(filter);        int rezultat = jf.showOpenDialog(null);        if(rezultat == JFileChooser.APPROVE_OPTION)        {            String excelPath = jf.getSelectedFile().getAbsolutePath();            ArrayList<Stavka>lista  = new ArrayList<>();            Stavka stavka = new Stavka();            File f = new File(excelPath);            Workbook wb = null;            try {                wb = Workbook.getWorkbook(f);            }            catch (BiffException e) {                e.printStackTrace();            }            catch (IOException e) {                e.printStackTrace();            }            // this is where i call for nested forloop            Sheet s = wb.getSheet(0);            int row = s.getRows();            int col = s.getColumns();            System.out.println("redovi" + row + "kolone" + col);如何解决这个问题?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 183 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信