package com.java.myapp;
import java.io.File;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
public class MyClass {
public static void main(String[] args) {
try{
String fileName = "C:\\java\\myExcel.xls";
WritableWorkbook workbook = Workbook.createWorkbook(new File(fileName));
/*** Sheet 1 ***/
WritableSheet ws1 = workbook.createSheet("mySheet1", 0);
ws1.addCell(new Label(0,0,"Data 1"));
ws1.addCell(new Label(0,1,"Data 2"));
ws1.addCell(new Label(0,2,"Data 3"));
/*** Sheet 2 ***/
WritableSheet ws2 = workbook.createSheet("mySheet2", 1);
ws2.addCell(new Label(0,0,"Data 4"));
ws2.addCell(new Label(0,1,"Data 5"));
ws2.addCell(new Label(0,2,"Data 6"));
workbook.write();
workbook.close();
System.out.println("Excel file created.");
}
catch (Exception e) {
e.printStackTrace();
}
}
}