Swift API för att konvertera HTML till DIF

Swift-bibliotek för att konvertera HTML till DIF

Använd Cells Conversion REST API för att skapa anpassade arbetsflöden för kalkylblad i Swift. Detta är en professionell lösning för att konvertera HTML till DIF och andra dokumentformat online med Swift.

Konvertera en HTML-fil till DIF i Swift

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

Att konvertera filformat från HTML till DIF är en komplex uppgift. Alla formatövergångar från HTML till DIF utförs av vår Swift SDK samtidigt som källbladets HTML kalkylblads huvudsakliga strukturella och logiska innehåll bibehålls. Vårt Swift-bibliotek är en professionell lösning för att konvertera HTML till DIF-filer online. Denna Cloud SDK ger Swift-utvecklare kraftfull funktionalitet och perfekt DIF-utdata.

Kodexempel i Swift med REST API för att konvertera HTML till DIF-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.html"
    let format:String? = "dif"     
    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.dif"
            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)


Hur man använder Swift API för att konvertera HTML till DIF

  1. Skapa ett konto påinstrumentbräda för att få gratis API kvot & auktoriseringsinformation
  2. Initiera CellsApi med klient-id, klienthemlighet, basadress och version API
  3. Anrop cellsWorkbookPutConvertWorkbook-metoden för att få den resulterande strömmen


Systemkrav

  1. macOS Monterey 12.4
  2. Swift 4.2