Giter VIP home page Giter VIP logo

anot-excel's Introduction

anot-excel

anot-excel helps in creating excel sheet by just passing a list of objects. The data in the list will be compared with annotations in the class to create excel. Configurations currently supported are filename, names of columns, position of columns, sorting and grouping the columns. Consider the following class. (More examples are provided in code)

@Excel(name = "sortAndGroup")
public class SortAndGroupVo {

@ExcelColumn(name="Name", position=3, sort = true, sortPriority=2)
String studentName;

@ExcelColumn(name="Year", position=2,  sort = true, sortPriority=1)
Integer year;

@ExcelColumn(name="School",position=1,group=true, sort = true)
String school;
}

Meaning of Annotations

  1. @Excel

    1. Specifies that objects of this class is used for excel export.
    2. Parameter name specifies the name of excel file.
  2. @ExcelColumn

    1. Marks the data member as a column in excel.
    2. Parameter 'name' specifies the name of the column. This is a Mandatory param.
    3. 'position' specifies the position of the column from left. This is a Mandatory param.
    4. 'sort' specifies whether that column should be sorted in excel. This is Optional.
    5. 'sortPriority' is used when multiple columns need to be sorted. In the above example, rows will be sorted by year first as it has higher priority(smaller the number, higher will be the priority). But if two years are same, name will be used to sort the rows. Default sortPriority is 0.

After creating a list of objects based on above class, i.e SortAndGroupVo, pass it to the generator to get the excel.

List list = new ArrayList();
list.add(new SortAndGroupVo("Abc", 9, "Oxford"));
list.add(new SortAndGroupVo("Def", 5, "Oxford"));
list.add(new SortAndGroupVo("Ghi", 1, "Oxford"));
list.add(new SortAndGroupVo("Jkl", 5, "Harvard"));
list.add(new SortAndGroupVo("Mno", 1, "Harvard"));
AnotExcelGenerator simpleExcelGenerator = new AnotExcelGenerator();
simpleExcelGenerator.generateExcel(list);

Excel obtained :

School Year Name
Harvard 1 Mno
5 Jkl
Oxford 1 Ghi
5 Def
9 Abc

anot-excel's People

Contributors

sharatsn123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.