Chào các bạn!
Mình ghi dữ liệu từ Table ra file excel bị lỗi ký tự, ai đã từng bị hay có cách khác phục hướng dẫn cho mình với. Cảm ơn rất nhiều!!!!!!!!!!!
Bị lỗi như thế này.
Mã:
 public void exportTable(JXTable table, File file) throws IOException{
        TableModel model = table.getModel();
       // final ImageIcon Error = new ImageIcon(getClass().getResource("Images/close.png")); 
        try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-32"))) {
            for (int i = 0; i < model.getColumnCount(); i++) {
                out.write(model.getColumnName(i)+"\t");
            }
            out.write("
");
            
            for (int i = 0; i < model.getRowCount(); i++) {
                for (int j = 0; j < model.getColumnCount(); j++) {
                    if (model.getValueAt(i, j)!=null) {
                        out.write(model.getValueAt(i, j).toString()+"\t");
                    }else{
                        out.write(""+"\t");
                    }
                }
                out.write("
");
            }
             
             if (JOptionPane.showConfirmDialog(null, "Tạo file thành công, tại địa chỉ: " + file + "
 Bạn có muốn mở file hay không?","Thành công",JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) {
                try{
                 Runtime.getRuntime().exec("rundll32 url.dll, FileProtocolHandler " +file);
                }catch(Exception ex){
                    JOptionPane.showMessageDialog(null, "Lỗi");
                }
            }
        }catch(Exception ioe){
            JOptionPane.showMessageDialog(null, "Tạo file không thành công","Thông báo lỗi",JOptionPane.ERROR_MESSAGE);
        }
        
    }