https://bz.apache.org/bugzilla/show_bug.cgi?id=58245

--- Comment #6 from Javen ONeal <[email protected]> ---
Created attachment 33067
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33067&action=edit
site documentation updates

Updated quick-guide to include for-each sheet iteration in the attached patch.

These are the changes that developers would need to make with attachment 33066


final XSSFWorkbook wb = new XSSFWorkbook();
wb.createSheet();

// =====================================================================
// Case 1: Existing code uses XSSFSheet for-each loop
// =====================================================================
// Original code (no longer valid)
for (XSSFSheet sh : wb) {
    sh.createRow(0);
}

// Option A:
for (XSSFSheet sh : (Iterable<XSSFSheet>) (Iterable<? extends Sheet>) wb) {
    sh.createRow(0);
}

// Option B (preferred for new code):
for (Sheet sh : wb) {
    sh.createRow(0);
}

// =====================================================================
// Case 2: Existing code creates an iterator variable
// =====================================================================
// Original code (no longer valid)
Iterator<XSSFSheet> it = wb.iterator();
XSSFSheet sh = it.next();
sh.createRow(0);

// Option A:
Iterator<XSSFSheet> it = (Iterator<XSSFSheet>) (Iterator<? extends Sheet>)
wb.iterator();
XSSFSheet sh = it.next();
sh.createRow(0);

// Option B (deprecated, but a quick-fix)
@SuppressWarnings("deprecation")
Iterator<XSSFSheet> it = wb.xssfSheetIterator();
XSSFSheet sh = it.next();
sh.createRow(0);

// Option C (preferred for new code):
Iterator<Sheet> it = wb.iterator();
Sheet sh = it.next();
sh.createRow(0);

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to