Create spreadsheets & documents with Go
Create a shareable spreadsheet from Go using only net/http and encoding/json — no third-party SDK. Marshal your rows, POST them, and read the URL from the response. Ideal for Go services, CLIs, and serverless functions that need to emit reports or exports.
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]any{
"title": "Q3 Revenue",
"sheets": []map[string]any{{
"rows": [][]any{
{"Month", "Revenue", "Growth"},
{"July", 48200, "+12%"},
},
}},
})
req, _ := http.NewRequest("POST",
"https://openofficeai.com/api/v1/sheets", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var out map[string]any
json.NewDecoder(resp.Body).Decode(&out)
println(out["url"].(string))
}How to create a spreadsheet with Go
- 1Copy your API key from the dashboard.
- 2Marshal a map with title + sheets[].rows and POST it to /api/v1/sheets.
- 3Set the Authorization and Content-Type headers on the request.
- 4Decode the JSON response and use out["url"].
Why use OpenOfficeAI with Go
- Standard library only — no external dependency to vendor.
- Great for Go microservices, CLIs, and Lambda functions.
- Compile-time safety around your data, JSON simplicity for the API.
Frequently asked questions
Do I need a Go Excel library like excelize?
No. OpenOfficeAI builds the file from your JSON. If you need the raw .xlsx, request /api/v1/download/{id}?format=xlsx and write the bytes to a file or HTTP response.
How do I handle errors and timeouts properly?
Use an http.Client with a Timeout, check resp.StatusCode (201 on success), and decode the error JSON body when it is not 2xx. The API returns clear error messages you can log.
Can I stream the generated PDF to my users?
Yes. After creating the document, GET /api/v1/download/{id}?format=pdf and io.Copy the response body straight to your http.ResponseWriter with the right Content-Type.
Start creating documents with Go
Free tier includes 500 API calls per month — no card required.