JExcel - Modify Multiple Cells Before Closing WritableWorkbook

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


JExcel - Modify Multiple Cells Before Closing WritableWorkbook



I am trying to put a title in cell (0,0) and then use a for() loop to add file paths into each following row. However, I am only able to add one line of code; after the title, no other cells in the Excel document are modified.


for()



Here's where I create the file:


private void chooseSheetActionPerformed(java.awt.event.ActionEvent evt) {
sheetNum = chooseSheet.getSelectedIndex() - 1;
try {
WritableWorkbook workbook = Workbook.createWorkbook(newXls);
workbook.createSheet("Sheet1", 0);
workbook.write();
workbook.close();

writeXls();
} catch (Exception ex) {
Logger.getLogger(NewScore.class.getName()).log(Level.SEVERE, null, ex);
}
}



And here's where I try to write to it:


public void writeXls() throws Exception {
Workbook wb = Workbook.getWorkbook(newXls);
WritableWorkbook copy = Workbook.createWorkbook(newXls, wb);
WritableSheet ws = copy.getSheet(sheetNum);
WritableCell cell;

// Body Part - Title
Label lab = new Label(0,0,partName);
cell = (WritableCell) lab;
ws.addCell(cell);
copy.write();
// Image Info
int i = 1;
for (File file : imageArray(dir)) {
Label label = new Label (0,i,"test" + i);
cell = label;
ws.addCell(cell);
copy.write();
i++;
}
copy.close();
}



Is there a way to make my for() loop work, or do I need to go about this a different way?


for()



Thanks!









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP