Exporting data to Excel documents is a common feature of almost any applications. Through this article, I’m very glad to share with you guys my experience in implementing Excel export function in a Spring Boot application with the help of Apache POI Excel library. Suppose that we have an existing Spring Boot project using Spring Data JPA and Hibernate to access data, Thymeleaf to render the view and MySQL as the database. The code examples below demonstrate how to retrieve information about users from the database, and generate an Excel file which the users can download onto their computers. 1. Code of Entity Classes and Repositories Interfaces We have the User entity class that maps to the users table in the database, as shown below: And the Role entity class that maps to the roles table in the database: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 package com.vishesh ; import javax.persistence.*; @Entity @Tab...
To start implementing, visit the below link: https://www.npmjs.com/package/ng2-charts/v/3.0.0-rc.2 and follow the instructions it mentions, going with the flow I will show you how it impacts your projects File structure: You can install ng2-charts using npm npm install ng2-charts@next --save Effect: Two folders gets added to node_modules You need to install and include Chart.js library in your application (it is a peer dependency of this library) (more info can be found in the official chart.js documentation) npm install chart.js --save API Import import { ChartsModule } from 'ng2-charts'; // In your App's module: imports: [ ChartsModule ] Chart types There is one directive for all chart types: baseChart, and there are 8 types of charts: line, bar, radar, pie, polarArea, doughnut, bubble and scatter.
Solid Principal Aims at designing application architecture in such a way so any new change made to application will not induce any defect S - Single Responsibility O - Open and Close Principal - Abstract class could be extended without breaking or changing existing code L - Liskov Substitution Principle - Ensure subclass follow contract of parent class using Inheritence. I - Interface Segregation Principal - Use Mulitple Interfaces instead of Single Large Interface D - Dependency Inversion Principal - Use Dependency Injection and Interfaces to Depend on Abstraction. Example to demonstrate Liskov abstract class Vehicle { abstract void start(); } class Car extends Vehicle { @Override void start() { System.out.println("Car is starting..."); } } public class Main { public static void main(String[] args) { Vehicle myCar = new Car(); ...
Comments
Post a Comment