A lightweight API that converts XLSX files into JSON. Try it on xlsx2json.tsak.net
It will turn...
...into...
{
"name" : "tables are cool.xlsx",
"spreadsheets" : [
{
"name" : "Sheet 1",
"columns" : [
"Tables",
"Are",
"Cool"
],
"rows" : [
[
"col 3 is",
"right-aligned",
"$1600"
],
[
"col 2 is",
"centered",
"$12"
],
[
"zebra stripes",
"are neat",
"$1"
]
]
}
]
}
...and vice versa.
Simply send an XLSX file via POST
and multipart/form-data
request to /
. Expected upload parameter name is file
.
Sample form
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>XSLX2JSON API</title>
</head>
<body>
<h1>XSLX to JSON to XLSX REST API</h1>
<form action="/" method="post" enctype="multipart/form-data">
<input type="file" name="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/json">
<button type="submit">Upload</button>
</form>
</body>
</html>
This either accepts an XLSX file or JSON file as part of a multipart/form-data
request. It expects name="file"
.
Sample XLSX upload
POST http://localhost:8000
Content-Type: multipart/form-data
-----------------------------1234567890
Content-Disposition: form-data; name="file"; filename="test.xlsx"
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
...
This endpoint accepts JSON if sent via POST
and with Content-Type: application/json
POST http://localhost:8000/json2xlsx
Accept: */*
Cache-Control: no-cache
Content-Type: application/json
{}
The format has to match the format that is returned by turning XLSX to JSON.
API_HOST
(defaultlocalhost
)API_PORT
(default8000
)DEBUG
(default0
), useDEBUG=1
to enable debug mode
go test && go build
Build, run the following command and then open localhost:8000.
DEBUG=1 ./xlsx2json-api
Note: If you run with DEBUG=1
, it will serve a simple HTML form on localhost:8000 for
testing.
Run the command below and then open localhost:8000.
docker run -p 8000:8000 tsak/xlsx2json-api
See xlsx2json-api.service systemd service definition.
To install:
adduser xlsx2json
- copy
xlsx2json-api
binary and.env
file to/home/xlsx2json
- place systemd service script in
/etc/systemd/system/
sudo systemctl enable xlsx2json-api.service
sudo systemctl start xlsx2json-api
sudo journalctl -f -u xlsx2json-api
The last command will show if the service was started.