Recently, you need to use the excel import function. When importing students, you need to specify the class to use excel to import data at one time!
Modifying previous Code supports conversion of reference classes in attributes.
The test object is a User object. The javabean structure is as follows:
Private String username;
Private int id;
Private String name;
Private Date birthday;
Private long height;
Private double salary;
Private User user;
Use the test code:
Map Header = new HashMap ();
Header. put ("no.", "id ");
Header. put ("username", "username ");
Header. put ("name", "name ");
Header. put ("birthday", "birthday ");
Header. put ("height", "height ");
Header. put ("salary", "salary ");
Header. put ("child", "user. username ");
Header. put ("child name", "user. name ");
Header. put ("birthday", "user. birthday ");
ExcelImport export = new ExcelImport (header );
// Export. init (new File ("src/user.xls "));
Export. init (new FileInputStream (new File ("src/user.xls ")));
List Users = export. bindToModels (User. class, true );
For (User u: users ){
System. out. println (u );
}
Conversion Result
Excel structure:
:
Http://download.csdn.net/detail/believer123/7317397