Created
December 26, 2013 07:08
-
-
Save chukitow/8130742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
{ | |
File archivo = new File("datos.xls"); | |
TableModel modelo = jTable1.getModel(); | |
FileWriter excel = new FileWriter(archivo); | |
for(int i = 0; i < modelo.getColumnCount(); i++) | |
{ | |
excel.write(modelo.getColumnName(i) + "/t"); | |
} | |
excel.write("\n"); | |
for(int i=0; i< modelo.getRowCount(); i++) | |
{ | |
for(int j=0; j < modelo.getColumnCount(); j++) | |
{ | |
String data = (String)modelo.getValueAt(i, j); | |
if(data == "null") | |
{ | |
data=""; | |
} | |
excel.write(data+"/t"); | |
} | |
excel.write("\n"); | |
} | |
excel.close(); | |
JOptionPane.showMessageDialog(null, "Archivo Creado"); | |
} catch (IOException ex) | |
{ | |
Logger.getLogger(Alumnos_view.class.getName()).log(Level.SEVERE, null, ex); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment