2017-10-30 4 views
0

제품 데이터베이스에서 간단한 인보이스를 작성하는 프로그램을 작성하고 있습니다. 사용자가 배열 목록에 추가 된 제품과 수량을 선택 했으므로 while 루프가 실행되면이 작업을 수행하지 않으려 고하므로 쓰기 가능한 노트북을 닫는 데 문제가 있습니다. 필자는 java.jxl 메소드의 기능에 관해서 제한적인 지식을 가지고 있으므로 도움이 크게 감사 할 것입니다.while 루프 (netbeans)를 사용하여 arraylist에서 Excel로 작성

public void write() { 
    try { 
     WritableWorkbook myexel = Workbook.createWorkbook(new 
       File("C:\\Users\\paulm\\Desktop\\Invoice.xls")); 
     WritableSheet mysheet = myexel.createSheet("MYSHEET", 0); 
     Label l = new Label(0, 0, "Products :"); 
     mysheet.addCell(l); 
     int count = 0; 
     while(SelectedArray.size() >=count){ 
      int n = count + 1; 
      String prodtoadd = SelectedArray.get(count).getSelected(); 
      Label ln = new Label(1, n, prodtoadd); 
      mysheet.addCell(ln); 
      myexel.write(); 
      count++; 
     } 
     myexel.close(); 
    } catch (Exception e) { } 
} 

답변

0
I think you check your while loop and format code like this. 
while(SelectedArray.size() >=count){ 
       int n = count + 1; 
       String prodtoadd = SelectedArray.get(count).getSelected(); 
       Label ln = new Label(1, n, prodtoadd); 
       mysheet.addCell(ln); 
       count++; 
      } 
    myexel.write(); 
    myexel.close(); 
+0

여전히 작동하지 않습니다 - 그것은 기록하거나 닫히고 결코 – Pamar