|
1 | | -# Xlsx builder |
2 | | -[](https://codecov.io/gh/etilite/xlsx-builder) |
| 1 | +# xlsx-builder |
| 2 | + |
| 3 | +`xlsx-builder` is a lightweight microservice built with Go, designed to generate XLSX files from HTTP JSON requests. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Fast and efficient XLSX file generation from http stream |
| 8 | +- Easy-to-use API for creating Microsoft Excel™ spreadsheets from JSON data |
| 9 | +- Dockerized for easy deployment |
3 | 10 |
|
4 | 11 | ## Usage |
5 | | -Request `POST http://localhost:8080/table/` |
6 | | - |
7 | | -Example JSON: |
8 | | -```JSON |
9 | | -{ |
10 | | - "header": [ |
11 | | - "date", |
12 | | - "id", |
13 | | - "price" |
14 | | - ], |
15 | | - "data": [ |
16 | | - [ |
17 | | - "01.01.2023", |
18 | | - 1, |
19 | | - 10.5 |
20 | | - ], |
21 | | - [ |
22 | | - "02.01.2023", |
23 | | - 2, |
24 | | - 20.3 |
25 | | - ], |
26 | | - [ |
27 | | - "03.01.2023", |
28 | | - 3, |
29 | | - "33" |
30 | | - ] |
31 | | - ] |
32 | | -} |
| 12 | +### Quick Start with Docker |
| 13 | + |
| 14 | +```sh |
| 15 | +docker run --rm -p 8080:8080 -e HTTP_ADDR=:8080 etilite/xlsx-builder:latest |
| 16 | +``` |
| 17 | + |
| 18 | +This will start the service and expose its API on port 8080. |
| 19 | + |
| 20 | +### API |
| 21 | + |
| 22 | +**Endpoint:** |
| 23 | + |
| 24 | +- `POST /api/build` |
| 25 | + |
| 26 | +**Request Body:** |
| 27 | + |
| 28 | +The request body should be a JSON object with the following structure: |
| 29 | + |
| 30 | +```json |
| 31 | +[ |
| 32 | + {"data": [1, "a", 2.1]}, |
| 33 | + {"data": [2, "some-cell-data", 2, "another-cell"]} |
| 34 | +] |
33 | 35 | ``` |
34 | | -Service responses with `.xlsx` file |
| 36 | + |
| 37 | +**Request Example:** |
| 38 | + |
| 39 | +Using `cURL`, you can make a request like this: |
| 40 | + |
| 41 | +```sh |
| 42 | +curl --location 'localhost:8080/api/build' \ |
| 43 | +--header 'Content-Type: application/json' \ |
| 44 | +--data '[ |
| 45 | + {"data": [1, "a", 2.1]}, |
| 46 | + {"data": [2, "some-cell-data", 2, "another-cell"]} |
| 47 | +]' -o sheet.xlsx |
| 48 | +``` |
| 49 | + |
| 50 | +**Response:** |
| 51 | + |
| 52 | +The response will be a binary XLSX file with the generated content. |
| 53 | + |
| 54 | +### Build from source |
| 55 | + |
| 56 | +```sh |
| 57 | +git clone https://github.com/your-repo/xlsx-builder.git |
| 58 | +cd xlsx-builder |
| 59 | +make run |
| 60 | +``` |
| 61 | +This will build and run app at `http://localhost:8080`. |
| 62 | + |
| 63 | +## License |
| 64 | + |
| 65 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 66 | + |
| 67 | +## Contributing |
| 68 | + |
| 69 | +If you'd like to contribute to the project, please open an issue or submit a pull request on GitHub. |
| 70 | + |
| 71 | +## Badges |
| 72 | + |
| 73 | +[](https://hub.docker.com/r/etilite/xlsx-builder) |
| 74 | +[](https://github.com/etilite/xlsx-builder/actions/workflows/docker.yml) |
| 75 | +[](https://github.com/etilite/xlsx-builder/actions/workflows/go.yml) |
| 76 | +[](https://codecov.io/gh/etilite/xlsx-builder) |
0 commit comments