Json2docs
package for create excel / pdf /html file using json template
Install / Use
/learn @sanda0/Json2docsREADME
json2docs
install
go get github.com/sanda0/json2docs
example
package main
import (
"fmt"
"log"
"github.com/sanda0/json2docs"
)
func main() {
formatJSON := []byte(`{
"Header": [
{"Line": 1, "Text": "Abc Company"},
{"Line": 2, "Text": "123 Main Street"},
{"Line": 3, "Text": "Special report"},
{"Line": 4, "Text": "Reporting period January to December 2018"}
],
"BodyHeader": [
{"Index": 1, "Text": "Code", "Width": 10},
{"Index": 2, "Text": "Name", "Width": 30},
{"Index": 3, "Text": "Quantity", "Width": 10},
{"Index": 4, "Text": "Price", "Width": 10},
{"Index": 5, "Text": "Total", "Width": 10},
{"Index": 6, "Text": "AVG", "Width": 10}
],
"BodyFields": [
{"Index": 1, "Field": "prodId", "Width": 10},
{"Index": 2, "Field": "description", "Width": 30},
{"Index": 3, "Field": "qty", "Width": 10},
{"Index": 4, "Field": "price", "Width": 10},
{"Index": 5, "Field": "amount", "Width": 10},
{"Index": 6, "Field": "avg", "Width": 10}
],
"Summary": [
{"Index": 1, "Text": "", "Width": 10},
{"Index": 2, "Text": "", "Width": 30},
{"Index": 3, "Text": "", "Width": 10},
{"Index": 4, "Text": "", "Width": 10},
{"Index": 5, "Text": "150.00", "Width": 10},
{"Index": 6, "Text": "10.00", "Width": 10}
]
}`)
dataJSON := []byte(`[
{
"prodId": "1",
"description": "Product 1",
"qty": 1,
"price": 10.00,
"amount": 10.00,
"avg": 5.00
},
{
"prodId": "2",
"description": "Product 2",
"qty": 1,
"price": 20.00,
"amount": 20.00,
"avg": 5.00
},
{
"prodId": "3",
"description": "Product 3",
"qty": 1,
"price": 30.00,
"amount": 30.00,
"avg": 5.00
},
{
"prodId": "4",
"description": "Product 4",
"qty": 1,
"price": 40.00,
"amount": 40.00,
"avg": 5.00
},
{
"prodId": "5",
"description": "Product 5",
"qty": 1,
"price": 50.00,
"amount": 50.00,
"avg": 5.00
},
{
"prodId": "3",
"description": "Product 3",
"qty": 1,
"price": 30.00,
"amount": 30.00,
"avg": 5.00
},
{
"prodId": "4",
"description": "Product 4",
"qty": 1,
"price": 40.00,
"amount": 40.00,
"avg": 5.00
},
{
"prodId": "5",
"qty": 1,
"price": 50.00,
"amount": 50.00,
"description": "Product 5",
"avg": 5.00
}
]`)
excelFilename,err := json2docs.ExcelTabularGenerator(formatJSON, dataJSON, "filename")
if err != nil {
log.Fatal(err)
}
pdfFilename,err := json2docs.PdfTabularGenerator(formatJSON, dataJSON,"filename")
if err != nil {
log.Fatal(err)
}
htmlFilename,err := json2docs.HtmlTabularGenerator(formatJSON, dataJSON,"filename")
if err != nil {
log.Fatal(err)
}
fmt.Println("Excel file generated:", excelFilename)
fmt.Println("pdf file generated:", pdfFilename)
fmt.Println("html file generated:", htmlFilename)
// /================================================================
}
<a href="https://www.buymeacoffee.com/sandakelum" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
350.8kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
summarize
350.8kSummarize or extract text/transcripts from URLs, podcasts, and local files (great fallback for “transcribe this YouTube/video”).
