Skip to content

Commit 92787f7

Browse files
committed
Remove test case and examples, Add new code examples.
1 parent ba525b4 commit 92787f7

File tree

406 files changed

+207
-18311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

406 files changed

+207
-18311
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,5 @@ target/
6464
.ipynb_checkpoints
6565
/.vscode
6666
/.swagger-codegen
67-
test-reports
6867
.idea
69-
test/
70-
TestData/
68+
integrationtests/

Examples/CompanySales.xlsx

22.6 KB
Binary file not shown.

Examples/EmployeeSalesSummary.xlsx

18.8 KB
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
import shutil
3+
import base64
4+
from asposecellscloud.apis.cells_api import CellsApi
5+
from asposecellscloud.models import *
6+
from asposecellscloud.requests import *
7+
8+
9+
EmployeeSalesSummaryXlsx = "EmployeeSalesSummary.xlsx"
10+
CompanySalesXlsx = "CompanySales.xlsx"
11+
RemoteFolder = "PythonSDK"
12+
RemoteOutputFolder = "PythonSDKOutput"
13+
# Get Cells Cloud SDK instance
14+
instance = CellsApi(os.getenv('CellsCloudClientId'),os.getenv('CellsCloudClientSecret'))
15+
16+
instance.upload_file( UploadFileRequest( CompanySalesXlsx, RemoteFolder + '/' + CompanySalesXlsx))
17+
instance.upload_file( UploadFileRequest( EmployeeSalesSummaryXlsx, RemoteFolder + '/' + EmployeeSalesSummaryXlsx))
18+
19+
# batch convert matched Xlsx files to PDF format files
20+
instance.post_batch_convert( PostBatchConvertRequest( batch_convert_request= BatchConvertRequest( source_folder= RemoteFolder , format="Pdf" , out_folder=RemoteOutputFolder , match_condition= MatchConditionRequest( regex_pattern= 'xlsx' ))))
21+
22+
# batch split matched Xlsx files to PDF format files
23+
instance.post_batch_split( PostBatchSplitRequest( batch_split_request= BatchSplitRequest( source_folder= RemoteFolder , format="png" , out_folder=RemoteOutputFolder , match_condition= MatchConditionRequest( regex_pattern= 'xlsx' ))))
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import os
2+
import sys
3+
from asposecellscloud.apis.cells_api import CellsApi
4+
from asposecellscloud.models import *
5+
from asposecellscloud.requests import *
6+
7+
instance = CellsApi(os.getenv('CellsCloudClientId'),os.getenv('CellsCloudClientSecret'))
8+
9+
remote_folder = 'SDKPython'
10+
CompanySalesXlsx = 'CompanySales.xlsx'
11+
EmployeeSalesSummaryXlsx = 'EmployeeSalesSummary.xlsx'
12+
response = instance.object_exists(ObjectExistsRequest( 'SDKPython'))
13+
if not response.exists :
14+
instance.create_folder( CreateFolderRequest('SDKPython') )
15+
print('Created SDKPython Folder.')
16+
response = instance.object_exists(ObjectExistsRequest( 'SDKPython/CompanySales.xlsx'))
17+
if not response.exists :
18+
instance.upload_file( UploadFileRequest( CompanySalesXlsx, remote_folder + '/' + CompanySalesXlsx))
19+
print('Uploaded CompanySales.xlsx.')
20+
instance.create_folder( CreateFolderRequest( 'SDKPython/CellsCloud'))
21+
response = instance.object_exists( ObjectExistsRequest('SDKPython/CellsCloud'))
22+
if response.exists :
23+
instance.move_folder( MoveFolderRequest( 'SDKPython/CellsCloud','SDKPython/CellsCloud2'))
24+
print('Moved folder.')
25+
instance.copy_file( CopyFileRequest( 'SDKPython/CompanySales.xlsx','SDKPython/CellsCloud/CompanySales.xlsx'))
26+
print('Copy CompanySales.xlsx exists.')
27+
instance.upload_file(UploadFileRequest(EmployeeSalesSummaryXlsx, 'SDKPython/CellsCloud2/' + EmployeeSalesSummaryXlsx))
28+
instance.copy_folder(CopyFolderRequest('SDKPython/CellsCloud2','SDKPython/CellsCloud' ))
29+
print('Copy folder.')
30+
fileLists = instance.get_files_list(GetFilesListRequest('SDKPython/CellsCloud'))
31+
print('Get files from folder.')
32+
for storageFile in fileLists.value:
33+
print(storageFile.name)
34+
instance.delete_folder( DeleteFolderRequest( 'SDKPython/CellsCloud2' , recursive=True))
35+
print('Deleted Folder.')
36+
instance.delete_folder(DeleteFolderRequest('SDKPython/CellsCloud', recursive=True))
37+
else :
38+
print('CompanySales.xlsx exists.')
39+
40+
instance.delete_file( DeleteFileRequest(remote_folder +'/'+ CompanySalesXlsx ))
41+
print('Delete CompanySales.xlsx.')

Examples/Example_ConvertExcel.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import os
2+
import shutil
3+
import base64
4+
from asposecellscloud.apis.cells_api import CellsApi
5+
from asposecellscloud.models import *
6+
from asposecellscloud.requests import *
7+
8+
9+
EmployeeSalesSummaryXlsx = "EmployeeSalesSummary.xlsx"
10+
RemoteFolder = "PythonSDK"
11+
# Get Cells Cloud SDK instance
12+
instance = CellsApi(os.getenv('CellsCloudClientId'),os.getenv('CellsCloudClientSecret'))
13+
14+
# Convert a local Excel file to another format file directly.
15+
response = instance.put_convert_workbook(PutConvertWorkbookRequest( EmployeeSalesSummaryXlsx, 'pdf'))
16+
shutil.move( response ,"EmployeeSalesSummary1.pdf")
17+
18+
# Upload a local Excel file to Cells Cloud Storage.
19+
instance.upload_file( UploadFileRequest(EmployeeSalesSummaryXlsx, "PythonSDK/EmployeeSalesSummary.xlsx"))
20+
# Convert an Excel file of Cells Cloud to another format file.
21+
response = instance.get_workbook( GetWorkbookRequest(EmployeeSalesSummaryXlsx , format='pdf' , folder=RemoteFolder) )
22+
shutil.move( response ,"EmployeeSalesSummary2.pdf")
23+
24+
#Save an Excel file of Cells Cloud as another format file of Cells Cloud.
25+
instance.post_workbook_save_as( PostWorkbookSaveAsRequest( EmployeeSalesSummaryXlsx ,newfilename= "PythonSDK/EmployeeSalesSummary.pdf" ,folder=RemoteFolder ))
26+
27+
# Convert a local Excel file to pdf file directly. The return value is a file info object, which includes of file name, file content(base64string), and file size.
28+
response = instance.post_convert_workbook_to_pdf( PostConvertWorkbookToPDFRequest( EmployeeSalesSummaryXlsx ,))
29+
filedata = base64.b64decode(response.file_content)
30+
with open("EmployeeSalesSummary.pdf", "wb") as file:
31+
file.write(filedata)
32+
33+
# Convert a local Excel file to pdf file directly. The return value is a file info object, which includes of file name, file content(base64string), and file size.
34+
response = instance.post_convert_workbook_to_json( PostConvertWorkbookToJsonRequest( EmployeeSalesSummaryXlsx ,))
35+
filedata = base64.b64decode(response.file_content)
36+
with open("EmployeeSalesSummary.json", "wb") as file:
37+
file.write(filedata)
38+
39+
40+
# Convert a local Excel file to docx file directly. The return value is a file info object, which includes of file name, file content(base64string), and file size.
41+
response = instance.post_convert_workbook_to_docx( PostConvertWorkbookToDocxRequest( EmployeeSalesSummaryXlsx ,))
42+
filedata = base64.b64decode(response.file_content)
43+
with open("EmployeeSalesSummary.docx", "wb") as file:
44+
file.write(filedata)
45+
46+
# Convert a local Excel file to png file directly. The return value is a file info object, which includes of file name, file content(base64string), and file size.
47+
response = instance.post_convert_workbook_to_png( PostConvertWorkbookToPNGRequest( EmployeeSalesSummaryXlsx ,))
48+
filedata = base64.b64decode(response.file_content)
49+
with open("EmployeeSalesSummary.png", "wb") as file:
50+
file.write(filedata)
51+
52+
# Convert a local Excel file to pptx file directly. The return value is a file info object, which includes of file name, file content(base64string), and file size.
53+
response = instance.post_convert_workbook_to_pptx(PostConvertWorkbookToPptxRequest(EmployeeSalesSummaryXlsx, ))
54+
filedata = base64.b64decode(response.file_content)
55+
with open("EmployeeSalesSummary.pptx", "wb") as file:
56+
file.write(filedata)
57+
58+
# Convert a local Excel file to html file directly. The return value is a file info object, which includes of file name, file content(base64string), and file size.
59+
response = instance.post_convert_workbook_to_html(PostConvertWorkbookToHtmlRequest(EmployeeSalesSummaryXlsx, ))
60+
filedata = base64.b64decode(response.file_content)
61+
with open("EmployeeSalesSummary.html", "wb") as file:
62+
file.write(filedata)
63+
64+
# Convert a worksheet of a local Excel file to another format file directly. Set query parameters : print_headings, one_page_per_sheet
65+
response = instance.get_worksheet_with_format( GetWorksheetWithFormatRequest(EmployeeSalesSummaryXlsx, "Sales", folder ="PythonSDK", format="png", print_headings=True , one_page_per_sheet= False ) )
66+
shutil.move( response ,"EmployeeSalesSummary_Sales.png")
67+
68+
# Convert a local Excel file's specified worksheet page index directly to another format file. Set query parameters : print_headings, one_page_per_sheet
69+
response = instance.get_worksheet_with_format( GetWorksheetWithFormatRequest(EmployeeSalesSummaryXlsx, "Sales", folder ="PythonSDK", format="png", page_index= 1 , print_headings=True , one_page_per_sheet= False ) )
70+
shutil.move( response ,"EmployeeSalesSummary_Sales_PageIndex.png")
71+
72+
# Convert a local Excel file's specified worksheet cells area directly to another format file. Set query parameters : print_headings, one_page_per_sheet
73+
response = instance.get_worksheet_with_format( GetWorksheetWithFormatRequest(EmployeeSalesSummaryXlsx, "Sales", folder ="PythonSDK", format="png", area="B5:L36" ,print_headings=True , one_page_per_sheet= False ) )
74+
shutil.move( response ,"EmployeeSalesSummary_Sales_area.png")
75+
76+
# Advanced Conversion allows you to flexibly set page parameters and save parameters
77+
dataSource = DataSource( data_source_type = 'CloudFileSystem' , data_path = RemoteFolder +'/' +EmployeeSalesSummaryXlsx )
78+
saveOptions = PdfSaveOptions( save_format ='pdf' , one_page_per_sheet = True )
79+
convertWorkbookOptions = ConvertWorkbookOptions( data_source= dataSource , convert_format = 'Pdf' ,save_options= saveOptions )
80+
response = instance.post_convert_workbook( PostConvertWorkbookRequest( convert_workbook_options=convertWorkbookOptions ) )
81+
filedata = base64.b64decode(response.file_content)
82+
with open("EmployeeSalesSummary3.pdf", "wb") as file:
83+
file.write(filedata)

Examples/Example_CopyFile.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

Examples/Example_CopyFolder.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

Examples/Example_CreateFolder.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

Examples/Example_DataProcessing.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
import shutil
3+
import base64
4+
from asposecellscloud.apis.cells_api import CellsApi
5+
from asposecellscloud.models import *
6+
from asposecellscloud.requests import *
7+
8+
9+
EmployeeSalesSummaryXlsx = "EmployeeSalesSummary.xlsx"
10+
CompanySalesXlsx = "CompanySales.xlsx"
11+
RemoteFolder = "PythonSDK"
12+
RemoteOutputFolder = "PythonSDKOutput"
13+
# Get Cells Cloud SDK instance
14+
instance = CellsApi(os.getenv('CellsCloudClientId'),os.getenv('CellsCloudClientSecret'))
15+
16+
instance.upload_file( UploadFileRequest( CompanySalesXlsx, RemoteFolder + '/' + CompanySalesXlsx))
17+
instance.upload_file( UploadFileRequest( EmployeeSalesSummaryXlsx, RemoteFolder + '/' + EmployeeSalesSummaryXlsx))
18+
19+
instance.post_batch_convert( BatchConvertRequest( source_folder= RemoteFolder , format="Pdf" , out_folder=RemoteOutputFolder , match_condition= MatchConditionRequest( regex_pattern= "*" )))

0 commit comments

Comments
 (0)