How to Fill in Table Data in a DOCX File in Go

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/convert/transform/docx/table/fill/data/edit-session"
method := "POST"
payload := strings.NewReader("InputFileUrl=%3Cstring%3E&InputFileData=%3Cbyte%3E&TableStartTag=%3Cstring%3E&TableEndTag=%3Cstring%3E&DataToFillIn=%7B%22Cells%22%3A%5B%7B%22TargetTag%22%3A%22%3Cstring%3E%22%2C%22ReplacementValue%22%3A%22%3Cstring%3E%22%7D%2C%7B%22TargetTag%22%3A%22%3Cstring%3E%22%2C%22ReplacementValue%22%3A%22%3Cstring%3E%22%7D%5D%7D&DataToFillIn=%7B%22Cells%22%3A%5B%7B%22TargetTag%22%3A%22%3Cstring%3E%22%2C%22ReplacementValue%22%3A%22%3Cstring%3E%22%7D%2C%7B%22TargetTag%22%3A%22%3Cstring%3E%22%2C%22ReplacementValue%22%3A%22%3Cstring%3E%22%7D%5D%7D")client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.