Skip to content

tarikelbannany/rain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rain

Object to excel spreed sheet

Object to Excel Java library. Based on apache POI library and the power of java reflexion.

JAVA version

GitHub Logo

mvn repo

<dependency>
  <groupId>net.xbaker</groupId>
  <artifactId>rain</artifactId>
  <version>2.0.0</version>
</dependency>

Create spreadsheet

let's give the User.java class

 public class User {
 
     @RainRow
     private String firstName;
     @RainRow(include = false)
     private String secondName;
     @RainRow
     private String address;
     @RainRow
     private String email;
     @RainRow(name = "PHONE")
     private String phone;
     @RainRow(child = {"label"})
     private City city;
     
     // getters and setters
 
 }

City.java class

 public class City {
     private String label;
     private String description;
     // getters && setters
 }

Test example

 public class MySpreadSheetRender {
     public MySpreadSheetRender() throws IOException {
          List<User> data = this.data();
           RainSheet<User> rainSheet = new RainSheetBuilder<User>()
                         .target(User.class)
                                         .multipleRowSeparator(MultipleRowSeparator.SPACE)
                                         .name("test")
                                         .insertChildRowName(true)
                                         .insertDateInName(false)
                                         .rowContent(data)
                                         .build();
         
           WorkBookGenerator<User> workBookGenerator = new WorkBookGenerator<>(rainSheet);
           Workbook workbook = workBookGenerator.render();
           FileOutputStream out = new FileOutputStream("example.xls");
                   workbook.write(out);
                   out.close();
     }
 }

My test result

About

Object to Excel file based on annotation

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages