Srs.
Bom dia a todos
Estou tendo dificuldade em gerar um .xls com varias linhas.
O que estou fazendo pegando as informações de um txt e criando um xls
nisso tenho que escrever linha a linha num total de 20 linhas ou seja 20 registros.
Só consigo inserir uma única linha, quando vou inserir a segunda dá erro.
Alguém poderia me ajudar nisso?!
private static void writeSheet(String trim, String trim2, int i) throws RowsExceededException, WriteException, IOException, BiffException {
int stringa3 ;
int v_count;
int v2 = 0;
int v3 = 1;
int v4;
int v5;
String filename3 = null;
File filename = new File("C:\\Arquivos_Executados\\output.xls");
if (!filename.exists()){
//Instanciando a classe q gera o novo arquivo do Excel
WritableWorkbook workbook = Workbook.createWorkbook(new File(filename.toString()));
//Criando uma nova planilha
WritableSheet sheet = workbook.createSheet("First Sheet", 1);
//==================================================================
if (v3 == 1){
v4 = 0;
v5 = 1;
}else{
v4 = v3;
v5 = v3+1;
}
//adicionando uma celula no formato de texto A1
//(colunas,linha,valor do campo)
Label label = new Label(0, 0, "REFERENCIA");
sheet.addCell(label);
// adicionando uma celula no formato de texto A1
//jxl.write.Number number = new jxl.write.Number(0, v5,trim);
//sheet.addCell(number);
System.out.println("trim "+trim);
Label label1 = new Label(0, v2, trim);
sheet.addCell(label1);
//=================================================================
// adicionando uma celula no formato de texto A2
Label label2 = new Label(1, 0, "BASE");
sheet.addCell(label2);
// adicionando uma celula no formato de texto A2
//jxl.write.Number number2 = new jxl.write.Number(1, 1, 3.1459);
//sheet.addCell(number2);
System.out.println("trim2 "+trim2);
Label label3 = new Label(1, v2, trim2);
sheet.addCell(label3);
//==================================================================
// Escrevedo o arquivo em disco
workbook.write();
// Fechando a IO
workbook.close();
}else{
System.out.println("ja existe!!!");
String filename32 = filename3;
Workbook rw = Workbook.getWorkbook (new File (filename32.toString()));
WritableWorkbook wwb = Workbook.createWorkbook (new File (filename32.toString()), rw);
WritableSheet sheet = wwb.getSheet (0);
int i1 = sheet.getRows();
int a = wwb.getNumberOfSheets();
// AQUI ELE ENTRA, SÓ QUE DEPOIS QUE EU ADICIONO O VALOR NO a+1, ELE FICA PULANDO DE SHEET, CRIANDO UMA LINHA POR SHEET
if (i1 <= 60000){
sheet = wwb.getSheet (0);
} else {
sheet = wwb.createSheet("Resultado", a+1);
sheet = wwb.getSheet(a);
}
//col, lin
Label label6 = new Label(0, i1, trim);
sheet.addCell(label6);
Label label7 = new Label(1, i1, trim2);
sheet.addCell(label7);
}
}
Ficarei muito grato.