Skip to content

Microservice to build xlsx spreadsheets from json

License

Notifications You must be signed in to change notification settings

etilite/xlsx-builder

Repository files navigation

xlsx-builder

docker pulls docker push go build codecov

xlsx-builder is a lightweight microservice written in Go that allows you to easily generate XLSX spreadsheets from JSON requests.

It can be perfect dedicated solution for projects looking to isolate their spreadsheet generation logic.

This microservice leverages Go's impressive performance and memory efficiency which can be useful for applications that handle large datasets .

Features

  • Fast and efficient XLSX file generation from http stream
  • Easy-to-use API for creating Microsoft Excel™ spreadsheets from JSON data
  • Dockerized for easy deployment

Usage

Quick Start with Docker

docker run --rm -p 8080:8080 -e HTTP_ADDR=:8080 etilite/xlsx-builder:latest

This will start the service and expose its API on port 8080.

API

Request

  • POST /api/build

Request Body:

The request body should be a JSON object with the following structure:

[
   {"data": [11, "a", 2.1]},
   {"data": [22, "some-cell-data", 2, "another-cell"]}
]

Where each object in array presents a single row in table and data is array of cell values in this row.

Request Example:

Using cURL, you can make a request like this:

curl --location 'localhost:8080/api/build' \
--header 'Content-Type: application/json' \
--data '[
    {"data": [11, "a", 2.1]},
    {"data": [22, "some-cell-data", 2, "another-cell"]}
]' -o sheet.xlsx

Response

The response will be a binary XLSX file with the generated content. For this particular example it is a table with 2 rows and 4 cols:

11 a 2.1
22 some-cell-data 2 another-cell

Build from source

git clone https://github.com/etilite/xlsx-builder.git
cd xlsx-builder
make run

This will build and run app at http://localhost:8080.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

If you'd like to contribute to the project, please open an issue or submit a pull request on GitHub.