Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Adding a worksheet to a workbook
Java
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Workbook object
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet worksheet = worksheets.add("My Worksheet");
//Saving the Excel file
workbook.save("newWorksheet.xls");Adding a worksheet to a workbook
Java
Workbook wb = new HSSFWorkbook(); // or new XSSFWorkbook();
Sheet sheet1 = wb.createSheet("new sheet");
Sheet sheet2 = wb.createSheet("second sheet");
// Note that sheet name in Excel must not exceed 31 characters
// and must not contain any of the following characters:
// 0x0000
// 0x0003
// colon (:)
// backslash (\)
// asterisk (*)
// question mark (?)
// forward slash (/)
// opening square bracket ([)
// closing square bracket (])
// You can use org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
// for a safe way to create valid names; this utility replaces invalid characters with a space (' ')
String safeName = WorkbookUtil.createSafeSheetName("[O'Brien's sales*?]");
Sheet sheet3 = wb.createSheet(safeName);
FileOutputStream fileOut = new FileOutputStream("newWorksheet.xls");
wb.write(fileOut);
fileOut.close();Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.