Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The below overwrites the existing sheet. But not create a new sheet.

What I have tried:

File f= new File(System.getProperty("user.dir")+"\\src\\test\\resources\\Exceldata.xls");		
		HSSFWorkbook workbook = new HSSFWorkbook();			
		HSSFSheet worksheet= workbook.createSheet("Sheet4");		
		HSSFRow row = worksheet.createRow(1);
		HSSFCell cell= row.createCell(1);
		cell.setCellValue("admin");		 
        workbook.write(f);
        workbook.close();
Posted
Updated 16-Oct-18 19:46pm

See Workbook (POI API Documentation)[^]. Always best to read the documentation first.
 
Share this answer
 
I had to downgrade apache poi jar from 4.0 to 3.14 to make it work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900