Java y Excel

Tigre Negro
14 de Febrero del 2006
Hola a todos, ¿alguien sabe como puedo leer mas de una hoja de un archivo de Excel?, estoy usando el API HSSF de Jakarta POI.

Saludos
Gracias de antemano

Julio Gomez Lethal
14 de Febrero del 2006
public class Read2 {

/**
* @param args
* @throws IOException
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
File excelFile = new File("c:\test.xls");
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(excelFile));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.createSheet("Sheet1");

HSSFRow row = sheet.getRow(1);
HSSFFont hssfFont = wb.createFont();
hssfFont.setFontName("Times New Roman");
hssfFont.setColor(HSSFColor.BLUE.index);
hssfFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
HSSFCellStyle style = wb.createCellStyle();
style.setFont(hssfFont);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setFillForegroundColor(HSSFColor.AQUA.index);
row.getCell((short)0).setCellStyle(style);

FileOutputStream fileOut = new FileOutputStream(excelFile);
wb.write(fileOut);
fileOut.close();

}

}

Lemony Snicket
14 de Febrero del 2006
Hay por ahí una API llamada JXL que para mi gusto es mejor que esa. Búscala en el Google.