import java.io.*;
import jxl.*;
import java.util.*;
import jxl.Workbook;
import jxl.write.DateFormats;
import jxl.write.Number;
import jxl.write.*;
//import java.text.SimpleDateFormat;
public class CreateExcel{
private static void writeDataSheet(WritableSheet s)throws WriteException{
WritableFont wf=new WritableFont(WritableFont.ARIAL,10,WritableFont.BOLD);
WritableCellFormat cf= new WritableCellFormat(wf);
cf.setWrap(true);
Label l = new Label(0,0,"My File",cf);
s.addCell(l);
/* WritableCellFormat cf1 =
new WritableCellFormat(DateFormats.FORMAT9);
DateTime dt =
new DateTime(0,1,new Date(), cf1, DateTime.GMT);
s.addCell(dt);
l = new Label(2,0,"Float", cf);
s.addCell(l);
WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT);
Number n = new Number(2,1,3.1415926535,cf2);
s.addCell(n);
n = new Number(2,2,-3.1415926535, cf2);
s.addCell(n);*/
}
private static void writeImageSheet(WritableSheet s)
throws WriteException{
Label l = new Label(0, 0, "Image");
s.addCell(l);
WritableImage wi = new WritableImage(0, 3, 5, 7, new File("image.png"));
s.addImage(wi);
}
public static void main(String args[]){
try{
String filename="Test.xml";
System.out.println(" " +filename);
WorkbookSettings ws =new WorkbookSettings();
ws.setLocale(new Locale("en","En"));
WritableWorkbook wwb= Workbook.createWorkbook(new File("filename"), ws);
WritableSheet s=wwb.createSheet("Sheet1",0);
WritableSheet s1=wwb.createSheet("Sheet1",0);
System.out.println("print" +s);
writeDataSheet(s);
writeImageSheet(s1);
wwb.write();
wwb.close();
}catch(IOException e){
e.printStackTrace();
}
catch(WriteException we){
we.printStackTrace();
}
}
}
import jxl.*;
import java.util.*;
import jxl.Workbook;
import jxl.write.DateFormats;
import jxl.write.Number;
import jxl.write.*;
//import java.text.SimpleDateFormat;
public class CreateExcel{
private static void writeDataSheet(WritableSheet s)throws WriteException{
WritableFont wf=new WritableFont(WritableFont.ARIAL,10,WritableFont.BOLD);
WritableCellFormat cf= new WritableCellFormat(wf);
cf.setWrap(true);
Label l = new Label(0,0,"My File",cf);
s.addCell(l);
/* WritableCellFormat cf1 =
new WritableCellFormat(DateFormats.FORMAT9);
DateTime dt =
new DateTime(0,1,new Date(), cf1, DateTime.GMT);
s.addCell(dt);
l = new Label(2,0,"Float", cf);
s.addCell(l);
WritableCellFormat cf2 = new WritableCellFormat(NumberFormats.FLOAT);
Number n = new Number(2,1,3.1415926535,cf2);
s.addCell(n);
n = new Number(2,2,-3.1415926535, cf2);
s.addCell(n);*/
}
private static void writeImageSheet(WritableSheet s)
throws WriteException{
Label l = new Label(0, 0, "Image");
s.addCell(l);
WritableImage wi = new WritableImage(0, 3, 5, 7, new File("image.png"));
s.addImage(wi);
}
public static void main(String args[]){
try{
String filename="Test.xml";
System.out.println(" " +filename);
WorkbookSettings ws =new WorkbookSettings();
ws.setLocale(new Locale("en","En"));
WritableWorkbook wwb= Workbook.createWorkbook(new File("filename"), ws);
WritableSheet s=wwb.createSheet("Sheet1",0);
WritableSheet s1=wwb.createSheet("Sheet1",0);
System.out.println("print" +s);
writeDataSheet(s);
writeImageSheet(s1);
wwb.write();
wwb.close();
}catch(IOException e){
e.printStackTrace();
}
catch(WriteException we){
we.printStackTrace();
}
}
}
إرسال تعليق