jxl writes data to excel

Partially import packages

import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

 


  public void expExcel(String structname,List> villageDep){

    try {
    // Users user = getUser(structid);
              // open the file

 WritableWorkbook book = Workbook.createWorkbook( new File("D:"+File.separator+"Street town user information"+File.separator+structname+".xls"));
              // Generate a worksheet named town street name, parameters 0 means this is the first page

WritableSheet sheet = book.createSheet(structname , 0);
              // The position of the named cell in the constructor of the Label object is the first column and the first row (0,0)

// and the cell content is test
              String[] title = {"login name", "user name", "password"};
              int m =0;

 for(m=0;m

           Label  lab= new  Label(m,0,title[m]);
               sheet.addCell(lab);
              }

for(int n=1;n

              String[] name = {(String) villageDep.get(n-1).get("ID"),(String) villageDep.get(n-1).get("STRUCTNAME"),"666666"};
              for(m=0;m

                Label  lab= new  Label(m,n,name[m]);
                sheet.addCell(lab);

 }
              }

// write data and close the file
             book.write();
             book.close();

}   catch  (Exception e)  {
             System.out.println(e);
         }
  }

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326986502&siteId=291194637
jxl