Package org.apache.poi.ss.util
Class WorkbookUtil
- java.lang.Object
-
- org.apache.poi.ss.util.WorkbookUtil
-
public class WorkbookUtil extends Object
Helper methods for when working with Usermodel Workbooks
-
-
Constructor Summary
Constructors Constructor Description WorkbookUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
createSafeSheetName(String nameProposal)
Creates a valid sheet name, which is conform to the rules.static String
createSafeSheetName(String nameProposal, char replaceChar)
Creates a valid sheet name, which is conform to the rules.static void
validateSheetName(String sheetName)
Validates sheet name.
-
-
-
Method Detail
-
createSafeSheetName
public static String createSafeSheetName(String nameProposal)
Creates a valid sheet name, which is conform to the rules. In any case, the result safely can be used forWorkbook.setSheetName(int, String)
.
Rules:- never null
- minimum length is 1
- maximum length is 31
- doesn't contain special chars: : 0x0000, 0x0003, / \ ? * ] [
- Sheet names must not begin or end with ' (apostrophe)
- Parameters:
nameProposal
- can be any string, will be truncated if necessary, allowed to be null- Returns:
- a valid string, "empty" if to short, "null" if null
-
createSafeSheetName
public static String createSafeSheetName(String nameProposal, char replaceChar)
Creates a valid sheet name, which is conform to the rules. In any case, the result safely can be used forWorkbook.setSheetName(int, String)
.
Rules:- never null
- minimum length is 1
- maximum length is 31
- doesn't contain special chars: : 0x0000, 0x0003, / \ ? * ] [
- Sheet names must not begin or end with ' (apostrophe)
- Parameters:
nameProposal
- can be any string, will be truncated if necessary, allowed to be nullreplaceChar
- the char to replace invalid characters.- Returns:
- a valid string, "empty" if to short, "null" if null
-
validateSheetName
public static void validateSheetName(String sheetName)
Validates sheet name.The character count
MUST
be greater than or equal to 1 and less than or equal to 31. The string MUST NOT contain the any of the following characters:- 0x0000
- 0x0003
- colon (:)
- backslash (\)
- asterisk (*)
- question mark (?)
- forward slash (/)
- opening square bracket ([)
- closing square bracket (])
- Parameters:
sheetName
- the name to validate- Throws:
IllegalArgumentException
- if validation fails
-
-