0

场景是首先我执行一个结果并创建 excel 并在其中更新。现在我再次执行第二个结果并尝试在不同行的同一张表中更新,但我试图在一张表中获得两个结果。它只显示第二个结果。

     FileOutputStream exlFileName= new FileOutputStream("D:\\Screenshot\\testExcel.xls");
     WritableWorkbook exlWorkBook = Workbook.createWorkbook(exlFileName);
     WritableSheet exlWorkSheet1 = exlWorkBook.createSheet("Preload data check",0);
     Label Sheet1cellContent = new Label(0,0,"LAST NAME",cellFormat);
     Label Sheet1cellContent1 = new Label(1,0,"FIRST NAME",cellFormat);
     Label Sheet1cellContent2 = new Label(2,0,"DOB",cellFormat);
     Label Sheet1cellContent3 = new Label(3,0,"GENDER",cellFormat);
     Label Sheet1cellContent4 = new Label(4,0,"ADMIT DATE AND TIME",cellFormat);
     Label Sheet1cellContent5 = new Label(5,0,"PROVIDER NAME",cellFormat);
     Label Sheet1cellContent6 = new Label(6,0,"BILL TYPE",cellFormat);
     Label Sheet1cellContent7 = new Label(7,0,"DOS DATE AND TIME",cellFormat);
     Label Sheet1cellContent8 = new Label(8,0,"SCREENSHOT",cellFormat);

     exlWorkSheet1.addCell(Sheet1cellContent);
     exlWorkSheet1.addCell(Sheet1cellContent1);
     exlWorkSheet1.addCell(Sheet1cellContent2);
     exlWorkSheet1.addCell(Sheet1cellContent3);
     exlWorkSheet1.addCell(Sheet1cellContent4);
     exlWorkSheet1.addCell(Sheet1cellContent5);
     exlWorkSheet1.addCell(Sheet1cellContent6);
     exlWorkSheet1.addCell(Sheet1cellContent7);
     exlWorkSheet1.addCell(Sheet1cellContent8);

这是我将得到的第一个结果,现在我为第二个结果编写代码。

 FileOutputStream exlFileName= new FileOutputStream("D:\\Screenshot\\testExcel.xls");   
 WritableWorkbook exlWorkBook = Workbook.createWorkbook(exlFileName); 
 WritableSheet exlWorkSheet1 = exlWorkBook.createSheet("Preload data check",0); 
 Label Sheet1cellContent10 = new Label(1,5,"CPT Description",cellFormat);
 Label Sheet1cellContent12 = new Label(2,5,"Modifier1",cellFormat);
 Label Sheet1cellContent13 = new Label(3,5,"Modifier2",cellFormat); 
 Label Sheet1cellContent14 = new Label(4,5,"ICD1",cellFormat);
 Label Sheet1cellContent15 = new Label(5,5,"ICD2",cellFormat); 
 Label Sheet1cellContent16 = new Label(6,5,"Dx Notes",cellFormat); 
 Label Sheet1cellContent17 = new Label(7,5,"DOS date",cellFormat); 
 Label Sheet1cellContent18 = new Label(8,5,"Provider name",cellFormat); 
 Label Sheet1cellContent19 = new Label(9,5,"Screenshot",cellFormat);            
 exlWorkSheet1.addCell(Sheet1cellContent9);
 exlWorkSheet1.addCell(Sheet1cellContent10);
 exlWorkSheet1.addCell(Sheet1cellContent12); 
 exlWorkSheet1.addCell(Sheet1cellContent13);
 exlWorkSheet1.addCell(Sheet1cellContent14); 
 exlWorkSheet1.addCell(Sheet1cellContent15);
 exlWorkSheet1.addCell(Sheet1cellContent16); 
 exlWorkSheet1.addCell(Sheet1cellContent17); 
 exlWorkSheet1.addCell(Sheet1cellContent18); 
 exlWorkSheet1.addCell(Sheet1cellContent19);

请帮我解决这个问题。

4

1 回答 1

0

不要总是创建工作簿和工作表,而是尝试查看工作簿或工作表是否已经存在。如果存在,则在编辑模式下打开它并添加新的结果集。

于 2013-10-11T11:18:12.277 回答