Skip to content

Instantly share code, notes, and snippets.

public XSSFSheet cloneSheet(int sheetIndex, String requestedName) {
validateSheetIndex(sheetIndex);
XSSFSheet sourceSheet = getSourceSheet(sheetIndex);
String targetName = resolveSheetName(sourceSheet, requestedName);
XSSFSheet clonedSheet = createSheet(targetName);
copySheetRelations(sourceSheet, clonedSheet);
copyExternalRelationships(sourceSheet, clonedSheet);
@CalebIddings
CalebIddings / cloneSheetManual.java
Created April 8, 2026 00:23
cloneSheet refactor
public XSSFSheet cloneSheet(int sheetNum, String newName) {
validateSheetIndex(sheetNum);
XSSFSheet srcSheet = sheets.get(sheetNum);
// 1. Name Resolution
String validatedName = resolveNewSheetName(srcSheet, newName);
XSSFSheet clonedSheet = createSheet(validatedName);
// 2. Relationship Cloning
copySheetRelationships(srcSheet, clonedSheet);