Swift API to convert XLT to DOCX

Swift library to convert XLT to DOCX

Use Cells Conversion REST API to create customized spreadsheet workflows in Swift. This is a professional solution to convert XLT to DOCX and other document formats online using Swift.

Convert a XLT file to DOCX in Swift

API
PUT
https://api.aspose.cloud/v3.0/cells/convert

Converting file formats from XLT to DOCX is a complex task. All XLT to DOCX format transitions is performed by our Swift SDK while maintaining the source XLT spreadsheet's main structural and logical content. Our Swift library is a professional solution to convert XLT to DOCX files online. This Cloud SDK gives Swift developers powerful functionality and perfect DOCX output.

Code example in Swift using REST API to convert XLT to DOCX format

// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-swift/
    import AsposeCellsCloud
    let expectation1 = self.expectation(description: "checkAuth")
    AsposeCellsCloudAPI.clientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    AsposeCellsCloudAPI.clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    AuthAspose.checkAuth()
    {
        (authError) in
        guard authError == nil else {
            XCTFail("error checkAuth")
            return
        }
        expectation1.fulfill()
    }
    self.waitForExpectations(timeout: testTimeout, handler: nil)        
    let expectation = self.expectation(description: "PutConvert")
    let workbook:String = "Book1.xlt"
    let format:String? = "docx"     
    let url1: URL? = getURL(workbook)
    let filedata = NSData(contentsOfFile: url1!.path)
    let password:String? = nil
    let outPath:String? = nil
    CellsAPI.cellsWorkbookPutConvertWorkbook(file: url1!, format: format, password: password, outPath: outPath)
    {
        (response, error) in
        guard error == nil else {
            let errorinfo = self.GetErrorDataInfo(error: error as! ErrorResponse)
            print("error info: \(errorinfo!)")
            XCTFail("error PutConvert")
            return
        }            
        if let response = response {
            //response is a Data of file, we may write it down and check it.
            let fileName = "dest.docx"
            let filePath = NSHomeDirectory()
            let fileManager = FileManager.default
            let path = "\(filePath)/tmp/\(fileName)"
            fileManager.createFile(atPath: path, contents:nil, attributes:nil)
            let handle = FileHandle(forWritingAtPath:path)
            handle?.write(response as Data)
            expectation.fulfill()
        }
    }
    self.waitForExpectations(timeout: testTimeout, handler: nil)


How to use Swift API to convert XLT to DOCX

  1. Create an account at Dashboard to get free API quota & authorization details
  2. Initialize CellsApi with Client Id, Client Secret, Base URL & API version
  3. Call cellsWorkbookPutConvertWorkbook method to get the resultant stream


System Requirements

  1. macOS Monterey 12.4
  2. Swift 4.2