how to create multiple sheets within a workbook using jexcel
how to create multiple sheets within a workbook using jexcel
This code shows how can you create multiple sheets within a workbook using the JExcel API.
For creating multiple sheet in the workbook we have to import jxl.write.WritableWorkbook class.
We have created a main method which we have code to create multiple sheets within a workbook.
We have created a class named CreateMultipleSheetsInWorkbook, in which we have defined a main method, which contains the code for creating the multiple sheets in a workbook.
package r4r.co.in;
import java.io.IOException;
import java.io.File;
import jxl.Workbook;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
public class CreateMultipleSheetsInWorkbook {
/**
* @param args
*/
public static void main(String[] args) throws IOException, WriteException{
// TODO Auto-generated method stub
try
{
WritableWorkbook workbook=Workbook.createWorkbook(new File("F:/JAVA PROJECTS/Jexcel/src/r4r/co/in/firstsheet.xls"));
workbook.createSheet("mysheet", 0);
workbook.createSheet("mysheet2", 1);
workbook.write();
workbook.close();
}
catch(IOException e)
{
e.printStackTrace();
}
catch(WriteException e)
{
e.printStackTrace();
}
}
}