Pessoal, estou tentando criar uma planilha em excel com a api JXL.
É o seguinte, recebo uma planilha, com alguns valores para fazer a consulta no bd, até aqui ok, ta feito.
Depois pego os resultados das consultas, e quero gravar no excel… só que tenho que criar o arquivo, e dependendo do valor, ele muda de método para ir buscar os resultados…
Ou seja, tenho que ficar gravando no mesmo arquivo até terminar os dados de entrada…
A dúvida é…
Não sei como fazer a lógica para isso, ficar gravando no excel os parametros em linhas e colunas enquanto estiver resultados, e se já tiver gravado algo, começar da linha que parou em diante… pois assim fica reescrevendo e deixando só o último registro…
[code]
package br.com.simcard;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
public class CriarExcel {   
  
    /*public static void main(String[] args) {   
        try{   
            CriarPlanilha();   
            System.out.println("Planilha escrita com sucesso");   
        } catch (NullPointerException npe){   
            npe.printStackTrace();   
        } catch (IOException ioe){   
            ioe.printStackTrace();   
        } catch (RowsExceededException ree){   
            ree.printStackTrace();   
        } catch (WriteException we){   
            we.printStackTrace();   
        }   
    }*/   
	
    public void CriarPlanilhaColetiva(String dispositivo, String codTecnologia, String apnConfigurada, String simCard,
    		String linha, String operadora, String apnProvisionada, String statusSIMCard, String fonte, String imei,
    		String imsi, String statusLinha, String consDados, String matricula) throws IOException, RowsExceededException, WriteException{   
           
       
    	GregorianCalendar calendar = new GregorianCalendar();   
        SimpleDateFormat formatador = new SimpleDateFormat("dd' de 'MMMMM' de 'yyyy' - 'HH'h'mm'min'ss's'");     
        System.out.println(formatador.format(calendar.getTime()));   
           
        String filename = "C://Consulta_Coletiva - "+formatador.format(calendar.getTime())+".xls"; 
    	
    	//Instanciando a classe q gera o novo arquivo do Excel   
        WritableWorkbook workbook = Workbook.createWorkbook(new File(filename));   
           
        //Criando uma nova planilha   
        WritableSheet sheet = workbook.createSheet("First Sheet", 0);   
        
    	//col, lin
        Label labelTitulo = new Label(0, 0, "Dispositivo");   
        sheet.addCell(labelTitulo);
        
        Label labelTitulo1 = new Label(1, 0, "SIMCard");   
        sheet.addCell(labelTitulo1);
        
        Label labelTitulo2 = new Label(2, 0, "Linha");   
        sheet.addCell(labelTitulo2);
        
        Label labelTitulo3 = new Label(3, 0, "Tecnologia");   
        sheet.addCell(labelTitulo3);
        
        Label labelTitulo4 = new Label(4, 0, "APN Configurada");   
        sheet.addCell(labelTitulo4);
        
        Label labelTitulo5 = new Label(5, 0, "Operadora");   
        sheet.addCell(labelTitulo5);
        
        Label labelTitulo6 = new Label(6, 0, "APN Provisionada");   
        sheet.addCell(labelTitulo6);
        
        Label labelTitulo7 = new Label(7, 0, "Status SIMCard");   
        sheet.addCell(labelTitulo7);
        
        Label labelTitulo8 = new Label(8, 0, "Fonte");   
        sheet.addCell(labelTitulo8);
        
        Label labelTitulo9 = new Label(9, 0, "IMEI");   
        sheet.addCell(labelTitulo9);
        
        Label labelTitulo10 = new Label(10, 0, "IMSI");   
        sheet.addCell(labelTitulo10);
        
        Label labelTitulo11 = new Label(11, 0, "Status Linha");   
        sheet.addCell(labelTitulo11);
        
        Label labelTitulo12 = new Label(12, 0, "Consumo de Dados");   
        sheet.addCell(labelTitulo12);
        
        Label labelTitulo13 = new Label(13, 0, "Matricula");   
        sheet.addCell(labelTitulo13);
        
        for(int i=1; i <= 7; i++){ // NÃO SEI QUE CONDIÇÃO USO PARA FICAR NO LOOP
        
    	//col, lin
        Label label = new Label(0, i, dispositivo);   
        sheet.addCell(label);
        
        Label label1 = new Label(1, i, simCard);   
        sheet.addCell(label1);
        
        Label label2 = new Label(2, i, linha);   
        sheet.addCell(label2);
        
        Label label3 = new Label(3, i, codTecnologia);   
        sheet.addCell(label3);
        
        Label label4 = new Label(4, i, apnConfigurada);   
        sheet.addCell(label4);
        
        Label label5 = new Label(5, i, operadora);   
        sheet.addCell(label5);
        
        Label label6 = new Label(6, i, apnProvisionada);   
        sheet.addCell(label6);
        
        Label label7 = new Label(7, i, statusSIMCard);   
        sheet.addCell(label7);
        
        Label label8 = new Label(8, i, fonte);   
        sheet.addCell(label8);
        
        Label label9 = new Label(9, i, imei);   
        sheet.addCell(label9);
        
        Label label10 = new Label(10, i, imsi);   
        sheet.addCell(label10);
        
        Label label11 = new Label(11, i, statusLinha);   
        sheet.addCell(label11);
        
        Label label12 = new Label(12, i, consDados);   
        sheet.addCell(label12);
        
        Label label13 = new Label(13, i, matricula);   
        sheet.addCell(label13);
        
        }
        
        // adicionando uma celula no formato de texto   
        /*Label label = new Label(0, 2, "A label record");   
        sheet.addCell(label);*/   
  
        // adicionando uma celula no formato de texto   
        /*jxl.write.Number number = new jxl.write.Number(3, 4, 3.1459);   
        sheet.addCell(number);*/   
           
        // Escrevedo o arquivo em disco   
        workbook.write();   
           
        // Fechando a IO   
        workbook.close();   
  
    }   
}  
  
    }   [/code]