|
1 | 1 | # Spring Sheet Ease
|
2 |
| -In services run on the Spring web framework, sometimes data must be offered in Excel instead of JSON. This library simplifies the process, allowing the conversion of JSON data to Excel files for download with just one annotation, bypassing the complexity of using tools like Apache POI |
3 |
| -# Usage |
| 2 | + |
| 3 | +Spring Sheet Ease is a powerful library designed to bridge the gap between JSON data and Excel files within applications built on the Spring web framework. It offers a straightforward solution for services requiring data presentation in Excel format, simplifying the conversion process by eliminating the need for direct interaction with complex libraries like Apache POI. With just one annotation, developers can easily convert JSON data into downloadable Excel files, enhancing data portability and user experience. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Simplified Excel File Creation:** Generate Excel files from JSON data with a single annotation. |
| 8 | +- **Customizable Options:** Control file naming, password protection, and data flattening to suit your needs. |
| 9 | +- **No Direct Apache POI Dependency:** Avoid the complexity of directly using Apache POI for Excel file generation. |
| 10 | + |
| 11 | +## Getting Started |
| 12 | + |
| 13 | +### Prerequisites |
| 14 | + |
| 15 | +Ensure you have a Spring-based project ready for integrating Spring Sheet Ease. |
| 16 | + |
| 17 | +### Installation |
| 18 | + |
| 19 | +Add the following dependency to your project's `pom.xml` file to include Spring Sheet Ease: |
| 20 | + |
4 | 21 | ```xml
|
5 | 22 | <dependency>
|
6 | 23 | <groupId>com.beoks</groupId>
|
7 | 24 | <artifactId>spring-web-excel</artifactId>
|
8 | 25 | <version>0.0.1-SNAPSHOT</version>
|
9 | 26 | </dependency>
|
10 | 27 | ```
|
11 |
| -You need only append `@ExcelDownload` annotation to Controller Method. |
| 28 | + |
| 29 | +### Usage |
| 30 | + |
| 31 | +To enable Excel file download functionality, append the `@ExcelDownload` annotation to a controller method as demonstrated below: |
| 32 | + |
12 | 33 | ```java
|
13 | 34 | @RestController
|
14 | 35 | @RequestMapping("/pet")
|
15 | 36 | public class PetController {
|
16 | 37 |
|
17 |
| - //this will response JSON |
| 38 | + // Responds with JSON data |
18 | 39 | @GetMapping
|
19 | 40 | List<Pet> get(){
|
20 | 41 | return Pet.getDummy();
|
21 | 42 | }
|
22 | 43 |
|
23 |
| - //this will response test.xlsx file |
| 44 | + // Responds with an Excel file named 'test.xlsx' |
24 | 45 | @GetMapping("/excel")
|
25 |
| - @ExcelDownload(fileName = "test.xlsx",password = "excelFilePassword", useFlatten = false) |
| 46 | + @ExcelDownload(fileName = "test.xlsx", password = "password123!", useFlatten = false) |
26 | 47 | List<Pet> getExcel(){
|
27 | 48 | return Pet.getDummy();
|
28 | 49 | }
|
29 | 50 | }
|
30 | 51 | ```
|
31 |
| -You can see the result in [resource](./src/test/resources) directory |
32 |
| - |
33 |
| -## Option |
34 |
| -| Option | Description | |
35 |
| -| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
36 |
| -| filename | Excel Filename, suffix must be .xlsx | |
37 |
| -| password | Excel file password, if use empty string encryption not applied, default is empty string | |
38 |
| -| useFlatten | An option to either flatten nested JSON data to place each item in a separate cell or to display nested data as a JSON string<br><br>When useFlatten is False<br>"Max" "2018-01-01" "DOG" {"name":"John","address":"123 Street","friends":[{"name":"Sarah","address":"456 Avenue","friends":null},{"name":"Robert","address":"789 Road","friends":null}]} <br><br>When useFlatten is True<br>Max 2018-01-01 DOG John 123 Street Sarah 456 Avenue null Robert 789 Road null <br>Bella 2019-01-01 CAT John 123 Street Sarah 456 Avenue null Robert 789 Road null <br>Charlie 2017-01-01 DOG Sarah 456 Avenue null<br> | |
| 52 | + |
| 53 | +### Examples |
| 54 | + |
| 55 | +Explore the provided examples in the [resource directory](./src/test/resources) for insights on implementation and output. |
| 56 | + |
| 57 | +## Configuration Options |
| 58 | + |
| 59 | +Customize the behavior of your Excel file generation with the following options: |
| 60 | + |
| 61 | +| Option | Description | |
| 62 | +|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 63 | +| `filename` | Sets the Excel file name (must have a `.xlsx` suffix). | |
| 64 | +| `password` | Secures the Excel file with a password. Leave as an empty string (`""`) for no encryption. Default is an empty string. | |
| 65 | +| `useFlatten`| Determines the structure of nested JSON data in the Excel file. <br>**False:** Displays nested data as a JSON string.<br>**True:** Flattens nested data, placing each item in a separate cell. | |
| 66 | + |
| 67 | +## Contributing |
| 68 | + |
| 69 | +Contributions to Spring Sheet Ease are welcome! Please refer to our contributing guidelines for detailed information on how you can contribute to the project. |
| 70 | + |
| 71 | +## License |
| 72 | + |
| 73 | +Spring Sheet Ease is open-source software licensed under the [MIT license](LICENSE). |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +This revised README provides a more structured approach to presenting the information, making it easier for users to understand the library's purpose, setup, and configuration. Including sections like "Getting Started," "Configuration Options," and "Contributing" can also encourage community engagement and provide clear guidance on how to use the library effectively. |
0 commit comments