Insert a Table into a Word Document in Swift

import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
var semaphore = DispatchSemaphore (value: 0)let parameters = "InputFileBytes=%3Cbyte%3E&InputFileUrl=%3Cstring%3E&TableID=reprehenderit%20fugiat%20Excepteur%20non%20irure&Path=voluptate%20ad%20nisi%20dolor&Width=mollit%20ad&WidthType=nostrud%20cupidatat%20Ut&TableRows=%5B%7B%22RowIndex%22%3A66021612%2C%22Path%22%3A%22sunt%20tempor%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-52618426%2C%22Path%22%3A%22laborum%20ex%20nulla%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=dolor%20anim%20consectetur%20id%20do&TopBorderSize=-48699561&TopBorderSpace=39428009&TopBorderColor=dolore%20aute&BottomBorderType=cillum%20E&BottomBorderSize=-25468925&BottomBorderSpace=-54605955&BottomBorderColor=est%20anim%20labore%20dolor%20Ut&LeftBorderType=dolore%20aute%20do%20officia%20sit&LeftBorderSize=-32092416&LeftBorderSpace=51220927&LeftBorderColor=exercitation%20qui%20Duis%20reprehenderit%20Lorem&RightBorderType=elit%20dolore&RightBorderSize=-98164652&RightBorderSpace=59012741&RightBorderColor=labore%20amet%20id%20sit%20ex&CellHorizontalBorderType=n&CellHorizontalBorderSize=38762590&CellHorizontalBorderSpace=-83261608&CellHorizontalBorderColor=mollit%20ipsum%20qui%20exercitati&CellVerticalBorderType=id%20pariatur%20et%20nostrud%20tempor&CellVerticalBorderSize=81600348&CellVerticalBorderSpace=88089454&CellVerticalBorderColor=nulla%20cupidatat&StartBorderType=consectetur%20nisi%20tempor%20velit%20laborum&StartBorderSize=-5561060&StartBorderSpace=74403043&StartBorderColor=magna%20esse&EndBorderType=aliqua%20mollit%20ad%20in%20cupidatat&EndBorderSize=-91030522&EndBorderSpace=33016279&EndBorderColor=nostrud&TableIndentationMode=incididunt%20pariatur%20voluptate%20et&TableIndentationWidth=84550725&InsertPlacement=%3Cstring%3E&InsertPath=%3Cstring%3E"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.cloudmersive.com/convert/edit/docx/insert-table")!,timeoutInterval: Double.infinity)
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.addValue("YOUR-API-KEY-HERE", forHTTPHeaderField: "Apikey")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
semaphore.signal()
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()

--

--

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

436 Followers

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