Example #1
0
    def test_cells_pivot_tables_put_worksheet_pivot_table(self):
        """
        Test case for cells_pivot_tables_put_worksheet_pivot_table

        Add a pivot table into worksheet.
        """
        name = 'TestCase.xlsx'
        sheet_name = 'Sheet4'
        request = CreatePivotTableRequest(use_same_source=True)
        request.name = "TestPivot"
        request.dest_cell_name = "C1"
        request.source_data = "Sheet1!C6:E13"
        sourceData = "Sheet1!C6:E13"
        destCellName = "C1"
        tableName = "TestPivot"
        useSameSource = 'true'
        folder = "Temp"
        AuthUtil.Ready(name, folder)
        result = self.api.cells_pivot_tables_put_worksheet_pivot_table(
            name,
            sheet_name,
            request=None,
            folder=folder,
            source_data=sourceData,
            dest_cell_name=destCellName,
            table_name=tableName,
            use_same_source=useSameSource)
        pass
    def test_cells_list_objects_post_worksheet_list_object_summarize_with_pivot_table(
            self):
        """
        Test case for cells_list_objects_post_worksheet_list_object_summarize_with_pivot_table

        
        """
        name = 'Book1.xlsx'
        sheet_name = 'Sheet7'
        listObjectIndex = 0
        destsheetName = "Sheet2"
        request = CreatePivotTableRequest(use_same_source=True)
        request.dest_cell_name = 'C1'
        request.name = 'testp'
        request.pivot_field_columns = [2]
        request.pivot_field_data = [0]
        request.pivot_field_rows = [1]
        request.source_data = '=Sheet2!A1:E8'
        folder = "PythonTest"
        result = AuthUtil.Ready(self.api, name, folder)
        self.assertTrue(len(result.uploaded) > 0)
        result = self.api.cells_list_objects_post_worksheet_list_object_summarize_with_pivot_table(
            name,
            sheet_name,
            listObjectIndex,
            destsheetName,
            request=request,
            folder=folder)
        self.assertEqual(result.code, 200)
        pass
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"

#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(
    apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Cells API SDK
api_client = asposecellscloud.ApiClient.ApiClient(apiKey, appSid, True)
cellsApi = CellsApi(api_client)

#set input file name
filename = "Sample_Test_Book.xls"
sheetName = "Sheet1"

body = CreatePivotTableRequest.CreatePivotTableRequest()
body.Name = "MyPivot"
body.SourceData = "A5:E10"
body.DestCellName = "H20"
body.UseSameSource = True
body.PivotFieldRows = [1]
body.PivotFieldColumns = [1]
body.PivotFieldData = [1]

#upload file to aspose cloud storage
storageApi.PutCreate(Path=filename, file=data_folder + filename)

try:
    #invoke Aspose.Cells Cloud SDK API to add a pivot table in a worksheet
    response = cellsApi.PutWorksheetPivotTable(name=filename,
                                               sheetName=sheetName,