I have a form with a jtable which loads an excel file inside it, the problem is that it doesn't load the ñs or special characters
I get those question symbols. this is the add button code
private void btn_importarActionPerformed(java.awt.event.ActionEvent evt) {
try {
for (int i = 0; i < jtabla.getRowCount(); i++) {
modelo.removeRow(i);
i -= 1;
}
} catch (Exception e) {
}
JFileChooser fileChooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivos Excel (*.xls)", "xls");
fileChooser.setAcceptAllFileFilterUsed(false);
fileChooser.setFileFilter(filter);
fileChooser.setDialogTitle("BUSCAR ARCHIVO");
if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
String ruta = fileChooser.getSelectedFile().getAbsolutePath();
File f = new File(ruta);
try {
Workbook wb = Workbook.getWorkbook(f);
Sheet s = wb.getSheet(0);
int row = s.getRows();
int col = s.getColumns();
String[] datos;
for (int i = 0; i < row; i++) {
datos = new String[col];
for (int j = 0; j < col; j++) {
Cell c = s.getCell(j, i);
datos[j] = c.getContents();
System.out.print(c.getContents());
}
System.out.println("");
if (i == 0) {
modelo.setColumnIdentifiers(datos);
} else {
modelo.addRow(datos);
}
}
jtabla.setModel(modelo);
} catch (Exception e) {
}
}
}
I've already been researching about converting to UTF-8 but I don't know when I should do it and how. try to convert the file FILE
or at the time of getContents
but it does not give me any result.
Thanks in advance
I found the Solution
I had to change the libraries to use, in the question I was using the jxl but then I used poi-3.7-20101029.jar
this is the code
bookstores
Button
I had to use the decimalformat for integer numeric data because it gave me an error