Skip to content

Commit

Permalink
for Aspose.Cells for Cloud swift SDK 20.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
leoluo5 committed Apr 30, 2020
1 parent 4a57be7 commit 437436c
Show file tree
Hide file tree
Showing 7 changed files with 1,405 additions and 1,047 deletions.
2 changes: 1 addition & 1 deletion AsposeCellsCloud.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "AsposeCellsCloud"
s.version = "20.1"
s.version = "20.4"
s.summary = "Aspose.Cells Cloud SDK for Swift."
s.swift_version = "4.1"

Expand Down
2 changes: 1 addition & 1 deletion AsposeCellsCloud/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>20.1</string>
<string>20.4</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
2,187 changes: 1,147 additions & 1,040 deletions AsposeCellsCloud/Swaggers/APIs/CellsAPI.swift

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions AsposeCellsCloudTests/AsposeCellsCloudTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,39 @@ class AsposeCellsCloudTests: XCTestCase {
}
}

internal func deleteFile(name: String, folder: String = "", completion: @escaping ()->Void) {

var path = ""
if (folder != "")
{
path = "\(folder)/\(name)"
}
else
{
path = name
}

CellsAPI.deleteFileWithRequestBuilder(path: path).execute { (response, error) -> Void in
guard error == nil else {
XCTFail("error delete file \(path)")
return
}
if response != nil {
completion()
} else {
XCTFail("error delete file \(name)")
}
}

}

internal func GetErrorDataInfo(error: ErrorResponse) -> String?
{
if case let ErrorResponse.error(_, data, _) = error {
let errorinfo = String(data: data!, encoding: String.Encoding.utf8)
return errorinfo
}
return nil
}

}
4 changes: 3 additions & 1 deletion AsposeCellsCloudTests/CellsSaveAsAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CellsSaveAsAPITests: AsposeCellsCloudTests {
{
let expectation = self.expectation(description: "testcellsSaveAsPostDocumentSaveAs")
let name:String = BOOK1
let saveOptions:SaveOptions? = nil
let saveOptions:SaveOptions? = PdfSaveOptions(enableHTTPCompression: nil, saveFormat: "xlsx", clearData: nil, cachedFileFolder: nil, validateMergedAreas: nil, refreshChartCache: nil, createDirectory: nil, sortNames: nil, calculateFormula: nil, checkFontCompatibility: nil, onePagePerSheet: true, compliance: nil, defaultFont: nil, printingPageType: nil, imageType: nil, desiredPPI: nil, jpegQuality: nil, securityOptions: nil)
let newfilename:String = "newbook.xlsx"
let isAutoFitRows:Bool? = true
let isAutoFitColumns:Bool? = true
Expand All @@ -50,6 +50,8 @@ class CellsSaveAsAPITests: AsposeCellsCloudTests {
{
(response, error) in
guard error == nil else {
let errorinfo = self.GetErrorDataInfo(error: error as! ErrorResponse)
print("error info: \(errorinfo!)")
XCTFail("error testcellsSaveAsPostDocumentSaveAs")
return
}
Expand Down
99 changes: 97 additions & 2 deletions AsposeCellsCloudTests/CellsWorkbookAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,11 @@ class CellsWorkbookAPITests: AsposeCellsCloudTests {
let horizontalResolution:Int32? = 100
let verticalResolution:Int32? = 90
let folder:String = TEMPFOLDER
let outFolder:String? = nil
let storage:String? = nil

uploadFile(name: name) {
CellsAPI.cellsWorkbookPostWorkbookSplit(name: name, format: format, from: from, to: to, horizontalResolution: horizontalResolution, verticalResolution: verticalResolution, folder: folder, storage: storage)
CellsAPI.cellsWorkbookPostWorkbookSplit(name: name, format: format, from: from, to: to, horizontalResolution: horizontalResolution, verticalResolution: verticalResolution, folder: folder, outFolder: outFolder, storage: storage)
{
(response, error) in
guard error == nil else {
Expand Down Expand Up @@ -810,14 +811,15 @@ class CellsWorkbookAPITests: AsposeCellsCloudTests {
let s1 = dateformatter.string(from: dateNow)
let name:String = "NewBook\(s1).xlsx" ;

let isWriteOver:Bool? = false
let folder:String = TEMPFOLDER
let templateFile:String? = "\(TEMPFOLDER)/\(BOOK1)"
let dataFile:String? = "\(TEMPFOLDER)/ReportData.xml"
let storage:String? = nil

self.uploadFile(name: BOOK1) {
self.uploadFile(name: "ReportData.xml") {
CellsAPI.cellsWorkbookPutWorkbookCreate(name: name, templateFile: templateFile, dataFile: dataFile, folder: folder, storage: storage)
CellsAPI.cellsWorkbookPutWorkbookCreate(name: name, templateFile: templateFile, dataFile: dataFile, isWriteOver: isWriteOver, folder: folder, storage: storage)
{
(response, error) in
guard error == nil else {
Expand Down Expand Up @@ -862,5 +864,98 @@ class CellsWorkbookAPITests: AsposeCellsCloudTests {
self.waitForExpectations(timeout: testTimeout, handler: nil)
}
*/

func testcellsWorkbookPutWorkbookBackground()
{
let expectation = self.expectation(description: "testcellsWorkbookPutWorkbookBackground")
let name:String = BOOK1

let url1: URL? = getURL("WaterMark.png")
let newImage = UIImage(contentsOfFile: url1!.path)
let imageData = newImage!.pngData()

let folder:String? = TEMPFOLDER
let storage:String? = nil

uploadFile(name: name) {
CellsAPI.cellsWorkbookPutWorkbookBackground(name: name, png: imageData! as NSData, folder: folder, storage: storage)
{
(response, error) in
guard error == nil else {
XCTFail("error testcellsWorkbookPutWorkbookBackground")
return
}

if let response = response {
XCTAssertEqual(response.code, 200)
expectation.fulfill()
}
}
}
self.waitForExpectations(timeout: testTimeout, handler: nil)
}

func testcellsWorkbookDeleteWorkbookBackground()
{
let expectation = self.expectation(description: "testcellsWorkbookDeleteWorkbookBackground")
let name:String = BOOK1
let folder:String? = TEMPFOLDER
let storage:String? = nil

uploadFile(name: name) {
CellsAPI.cellsWorkbookDeleteWorkbookBackground(name: name, folder: folder, storage: storage)
{
(response, error) in
guard error == nil else {
XCTFail("error testcellsWorkbookDeleteWorkbookBackground")
return
}

if let response = response {
XCTAssertEqual(response.code, 200)
expectation.fulfill()
}
}
}
self.waitForExpectations(timeout: testTimeout, handler: nil)
}

func testcellsWorkbookPutWorkbookCreateNew()
{
let expectation = self.expectation(description: "testcellsWorkbookPutWorkbookCreateNew")

let dateformatter = DateFormatter()
dateformatter.dateFormat = "YYYYMMddHHmmss"
let dateNow = Date()
let s1 = dateformatter.string(from: dateNow)
let name:String = "NewBook\(s1).xlsx" ;

let isWriteOver:Bool? = true
let folder:String = TEMPFOLDER
let templateFile:String? = "\(TEMPFOLDER)/\(BOOK1)"
let dataFile:String? = "\(TEMPFOLDER)/ReportData.xml"
let storage:String? = nil

self.uploadFile(name: BOOK1) {
self.uploadFile(name: "ReportData.xml") {
CellsAPI.cellsWorkbookPutWorkbookCreate(name: name, templateFile: templateFile, dataFile: dataFile, isWriteOver: isWriteOver, folder: folder, storage: storage)
{
(response, error) in
guard error == nil else {
XCTFail("error testcellsWorkbookPutWorkbookCreateNew")
return
}

if let response = response {
XCTAssertEqual(response.code, 200)
expectation.fulfill()
}
}
}
}
self.waitForExpectations(timeout: testTimeout, handler: nil)
}


}

123 changes: 121 additions & 2 deletions AsposeCellsCloudTests/CellsWorksheetsAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,13 @@ class CellsWorksheetsAPITests: AsposeCellsCloudTests {
let format:String? = "png"
let verticalResolution:Int32? = 100
let horizontalResolution:Int32? = 90
let area:String? = nil
let pageIndex:Int32? = nil
let folder:String = TEMPFOLDER
let storage:String? = nil

uploadFile(name: name) {
CellsAPI.cellsWorksheetsGetWorksheet(name: name, sheetName: sheetName, format: format, verticalResolution: verticalResolution, horizontalResolution: horizontalResolution, folder: folder, storage: storage)
CellsAPI.cellsWorksheetsGetWorksheet(name: name, sheetName: sheetName, format: format, verticalResolution: verticalResolution, horizontalResolution: horizontalResolution, area: area, pageIndex: pageIndex, folder: folder, storage: storage)
{
(response, error) in
guard error == nil else {
Expand All @@ -244,7 +246,7 @@ class CellsWorksheetsAPITests: AsposeCellsCloudTests {

if let response = response {
//response is a Data of json, we may write it down and check it.
let fileName = "testcellsWorksheetsGetWorksheet.txt"
let fileName = "testcellsWorksheetsGetWorksheet.\(format!)"
let filePath = NSHomeDirectory()
let fileManager = FileManager.default
let path = "\(filePath)/tmp/\(fileName)"
Expand All @@ -259,6 +261,45 @@ class CellsWorksheetsAPITests: AsposeCellsCloudTests {
self.waitForExpectations(timeout: testTimeout, handler: nil)
}

func testcellsWorksheetsGetWorksheetToPDF()
{
let expectation = self.expectation(description: "testcellsWorksheetsGetWorksheetToPDF")
let name:String = BOOK1
let sheetName:String = SHEET1
let format:String? = "pdf"
let verticalResolution:Int32? = 100
let horizontalResolution:Int32? = 90
let area:String? = nil
let pageIndex:Int32? = nil
let folder:String = TEMPFOLDER
let storage:String? = nil

uploadFile(name: name) {
CellsAPI.cellsWorksheetsGetWorksheet(name: name, sheetName: sheetName, format: format, verticalResolution: verticalResolution, horizontalResolution: horizontalResolution, area: area, pageIndex: pageIndex, folder: folder, storage: storage)
{
(response, error) in
guard error == nil else {
XCTFail("error testcellsWorksheetsGetWorksheetToPDF")
return
}

if let response = response {
//response is a Data of json, we may write it down and check it.
let fileName = "testcellsWorksheetsGetWorksheetToPDF.\(format!)"
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)
}

func testcellsWorksheetsGetWorksheetCalculateFormula()
{
let expectation = self.expectation(description: "testcellsWorksheetsGetWorksheetCalculateFormula")
Expand Down Expand Up @@ -956,6 +997,84 @@ class CellsWorksheetsAPITests: AsposeCellsCloudTests {
}
self.waitForExpectations(timeout: testTimeout, handler: nil)
}

func testcellsWorksheetsGetWorksheetForArea()
{
let expectation = self.expectation(description: "testcellsWorksheetsGetWorksheetForArea")
let name:String = BOOK1
let sheetName:String = SHEET1
let format:String? = "png"
let verticalResolution:Int32? = 100
let horizontalResolution:Int32? = 90
let area:String? = "B3:K8"
let pageIndex:Int32? = nil
let folder:String = TEMPFOLDER
let storage:String? = nil

uploadFile(name: name) {
CellsAPI.cellsWorksheetsGetWorksheet(name: name, sheetName: sheetName, format: format, verticalResolution: verticalResolution, horizontalResolution: horizontalResolution, area: area, pageIndex: pageIndex, folder: folder, storage: storage)
{
(response, error) in
guard error == nil else {
XCTFail("error testcellsWorksheetsGetWorksheetForArea")
return
}

if let response = response {
//response is a Data of json, we may write it down and check it.
let fileName = "testcellsWorksheetsGetWorksheetForArea.\(format!)"
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)
}

func testcellsWorksheetsGetWorksheetForPageIndex()
{
let expectation = self.expectation(description: "testcellsWorksheetsGetWorksheetForPageIndex")
let name:String = BOOK1
let sheetName:String = SHEET1
let format:String? = "png"
let verticalResolution:Int32? = 100
let horizontalResolution:Int32? = 90
let area:String? = nil
let pageIndex:Int32? = 1
let folder:String = TEMPFOLDER
let storage:String? = nil

uploadFile(name: name) {
CellsAPI.cellsWorksheetsGetWorksheet(name: name, sheetName: sheetName, format: format, verticalResolution: verticalResolution, horizontalResolution: horizontalResolution, area: area, pageIndex: pageIndex, folder: folder, storage: storage)
{
(response, error) in
guard error == nil else {
XCTFail("error testcellsWorksheetsGetWorksheetForPageIndex")
return
}

if let response = response {
//response is a Data of json, we may write it down and check it.
let fileName = "testcellsWorksheetsGetWorksheetForPageIndex.\(format!)"
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)
}

}

0 comments on commit 437436c

Please sign in to comment.