Insert a Table into a DOCX File in Go

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/convert/edit/docx/insert-table"
method := "POST"
payload := strings.NewReader("InputFileBytes=%3Cbyte%3E&InputFileUrl=%3Cstring%3E&TableID=do%20commodo%20ex%20magna&Path=occaecat&Width=do%20non%20et%20consectetur&WidthType=incididunt%20consequat%20occaecat%20Excepteur%20c&TableRows=%5B%7B%22RowIndex%22%3A-71515190%2C%22Path%22%3A%22occaecat%22%2C%22RowCells%22%3A%5B%7B%22CellIndex%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22Path%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22Paragraphs%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingColor%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingFill%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingPattern%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellWidthMode%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellWidth%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%7D%2C%7B%22CellIndex%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22Path%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22Paragraphs%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingColor%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingFill%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingPattern%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellWidthMode%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellWidth%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%7D%5D%7D%2C%7B%22RowIndex%22%3A-53337796%2C%22Path%22%3A%22amet%20et%20in%20sunt%20aute%22%2C%22RowCells%22%3A%5B%7B%22CellIndex%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22Path%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22Paragraphs%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingColor%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingFill%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingPattern%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellWidthMode%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellWidth%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%7D%2C%7B%22CellIndex%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22Path%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22Paragraphs%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingColor%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingFill%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellShadingPattern%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellWidthMode%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%2C%22CellWidth%22%3A%7B%22value%22%3A%22%3CError%3A%20Too%20many%20levels%20of%20nesting%20to%20fake%20this%20schema%3E%22%7D%7D%5D%7D%5D&TopBorderType=amet%20labore%20Duis&TopBorderSize=-26319087&TopBorderSpace=29154048&TopBorderColor=magna%20adipisicing&BottomBorderType=nisi%20cupidatat%20aliqua&BottomBorderSize=53164256&BottomBorderSpace=-18289756&BottomBorderColor=dolore%20Duis&LeftBorderType=nostrud%20nulla%20sint&LeftBorderSize=24332009&LeftBorderSpace=-21105411&LeftBorderColor=cupidatat%20in%20sed%20eu&RightBorderType=aliqua%20voluptate%20esse%20exercitation&RightBorderSize=59237299&RightBorderSpace=80719970&RightBorderColor=elit%20amet&CellHorizontalBorderType=ad%20sint&CellHorizontalBorderSize=26051102&CellHorizontalBorderSpace=-54839842&CellHorizontalBorderColor=labore&CellVerticalBorderType=et%20adipisicing%20qui%20in&CellVerticalBorderSize=-94624917&CellVerticalBorderSpace=92127897&CellVerticalBorderColor=dolore%20officia%20cillum%20Excepteur&StartBorderType=ea%20labor&StartBorderSize=-82836407&StartBorderSpace=-21789487&StartBorderColor=fugiat%20ut%20id%20aliqua&EndBorderType=esse%20Excepteur&EndBorderSize=77618805&EndBorderSpace=-76834293&EndBorderColor=aliquip%20do&TableIndentationMode=id%20dolor%20sint%20cupidatat%20sed&TableIndentationWidth=-15290315&InsertPlacement=%3Cstring%3E&InsertPath=%3Cstring%3E")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.