jxl and excel poi Java written two ways of

First introduced JXL

1: Import jxl.jar

2: Code

public  static  void main (Straing [] args) { 
   String [] title = { "ID", "name", "Sex"}; // with the memory array header
    // Create an Excel file 
   File File = new new Feil ( "C : /jxl_test.xls ");     // Ctrl + O + Shift incorporated File 
    file.createNewFile (); 
    WritableWorkbook Workbook = Workbook.createWorkbook (File); // create a working portion 
       WritableSheet sheet = workbook.createSheet (" sheet1 " , 0 );
         // add data to 
     the Lable Lable = null ; // used to keep the data 
 for ( int I = 0; I <title.length; I ++) { //The first line sets the column name 
      Lable = new new the Lable (I, 0 , title [I]); 
      sheet.addCell (Lable); 
  }    
   for ( int I = 0; I <10; I ++ ) { 
     label = new new the Label (0, I, "a" + 1'd);   // the label column is the first number, the second number is the row, the third number is the data to be stored 
     shet.addCell (label); 
     label = new new the label (. 1 , I, "User" + 1'd ); 
     sheet.addCell (label); 
     label = new new the label (2, I, "Boy" ); 
     sheet.addCell (label);    
  } 
}

Guess you like

Origin www.cnblogs.com/JLU-Dragon/p/12158362.html