Git Product home page Git Product logo

reportwriter's Introduction

reportwriter

A rapid CSV generator based on annotation processing

A bean class defined like so :

class Bean{
	@WriteField(columnName="First Name", intoColumn=1)
	private String firstName;
	@WriteField(columnName="Last Name", intoColumn=2)
	private String lastName;
	@WriteField(columnName="Age", intoColumn=3)
	private int age;
	@WriteField(columnName="Marks", intoColumn=4)
	private double marks;
	public Bean(String firstName, String lastName, int age, double marks) {
		this.firstName = firstName;
		this.lastName = lastName;
		this.age = age;
		this.marks = marks;
	}
}

Can be converted into a CSV easily :

public class Main {
	public static void main(String[] args) {
		String filePath="C:\\report.csv";
		if(args.length>0){
			filePath=args[0];
		}
		ArrayList<Bean> list=new ArrayList<Bean>();
		list.add(new Bean("Max", "Payne", 25, 34.9));
		list.add(new Bean("Frank", "Roosevelt", 21, 74.9));
		list.add(new Bean("Theodore", "Heski", 55, 84.9));
		list.add(new Bean("Wayne", "Rooney", 49, 94.9));
		list.add(new Bean("Will", "Smith", 55, 84.9));
		ReportWriter writer=new ReportWriter(Bean.class, list, ReportWriterConstants.APPEND, filePath, ",", true);
		try{
			writer.generateReport();
			System.out.println("Sample report generated at : "+filePath);
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
}

Result :

First Name,Last Name,Age,Marks
Max,Payne,25,34.9
Frank,Roosevelt,21,74.9
Theodore,Heski,55,84.9
Wayne,Rooney,49,94.9

reportwriter's People

Contributors

kaos2404 avatar

Watchers

SHALABH JIBHAKATE 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.