public void Cells_Workbook_Tests()
        {
            try
            {
                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/cells-sample.xlsx", Utils.CloudStorage_Output_Folder + "/cells-sample.xlsx");

                WorkbookResponse WorkbookResponse = cellsService.Workbook.ReadWorkbookInfo(name, string.Empty, true, Utils.CloudStorage_Output_Folder);
                cellsService.Workbook.ExportWorkbook(name, WorkbookExportFormat.Pdf, string.Empty, false, Utils.CloudStorage_Output_Folder, Utils.Local_Output_Path + "cells-workbook-pdf.pdf");
                cellsService.Workbook.ExportWorkbook(name, WorkbookExportFormat.Pdf, string.Empty, false, Utils.CloudStorage_Output_Folder, Utils.CloudStorage_Output_Folder + "/cells-workbook-pdf.pdf");

                //To test
                //WorkbookResponse WorkbookResponse2 = cellsService.Workbook.CreateNewWorkbookUsingDeferentMethods(name, "templateFile", "dataFile", Utils.CloudStorage_Output_Folder);

                cellsService.Workbook.ConvertWorkbookToSomeFormat(WorkbookExportFormat.Pdf, string.Empty, Utils.CloudStorage_Output_Folder + "/cells-workbook-pdf2.pdf", Utils.Local_Input_Path + name);

                WorkbookEncryptionRequest workbookEncryptionRequest = new WorkbookEncryptionRequest(WorkbookEncryptionType.XOR, 128, "Aspose");
                cellsService.Workbook.EncriptDocument(name, Utils.CloudStorage_Output_Folder, workbookEncryptionRequest);
                cellsService.Workbook.DecryptDocument(name, Utils.CloudStorage_Output_Folder, workbookEncryptionRequest);

                WorkbookStyleResponse     WorkbookStyleResponse     = cellsService.Workbook.ReadWorkbookDefaultStyleInfo(name, Utils.CloudStorage_Output_Folder);
                WorkbookTextItemsResponse WorkbookTextItemsResponse = cellsService.Workbook.ReadWorkbooksTextItems(name, Utils.CloudStorage_Output_Folder);
                WorkbookNamesResponse     WorkbookNamesResponse     = cellsService.Workbook.ReadWorkbooksNames(name, Utils.CloudStorage_Output_Folder);
                WorkbookNameResponse      WorkbookNameResponse      = cellsService.Workbook.ReadWorkbooksName(name, "TestName", Utils.CloudStorage_Output_Folder);

                ProtectDocumentRequest protectDocumentRequest = new ProtectDocumentRequest();
                protectDocumentRequest.Password = "******";

                cellsService.Workbook.ProtectDocumentFromChanges(name, Utils.CloudStorage_Output_Folder, protectDocumentRequest);
                cellsService.Workbook.UnprotectDocumentFromChanges(name, Utils.CloudStorage_Output_Folder, protectDocumentRequest);

                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/cells-sample.xlsx", Utils.CloudStorage_Output_Folder + "/cells-sample2.xlsx");
                WorkbookResponse WorkbookResponse4 = cellsService.Workbook.MergeWorkbooks(name, Utils.CloudStorage_Output_Folder + "/cells-sample2.xlsx", Utils.CloudStorage_Output_Folder);

                CellsTextItemsResponse      CellsTextItemsResponse      = cellsService.Workbook.SearchText(name, "Student1", Utils.CloudStorage_Output_Folder);
                WorkbookReplaceTextResponse WorkbookReplaceTextResponse = cellsService.Workbook.ReplaceText(name, "Student", "Employee", Utils.CloudStorage_Output_Folder);

                //To test
                //WorkbookResponse WorkbookResponse5 = cellsService.Workbook.SmartMarkerProcessingResult(name, "xmlFile", Utils.CloudStorage_Output_Folder, "outPath");

                WorkbookSplitResponse WorkbookSplitResponse = cellsService.Workbook.SplitWorkbook(name, CellsSplitFormat.Gif, 1, 2, 0, 0, Utils.CloudStorage_Output_Folder);

                //To test
                //cellsService.Workbook.ImportDataToWorkbook(name, Utils.CloudStorage_Output_Folder, WorkbookImportOption);

                cellsService.Workbook.CalculateAllFormulasInWorkbook(name, Utils.CloudStorage_Output_Folder);

                CellsAutoFitterOptionsRequest autoFitterOptions = new CellsAutoFitterOptionsRequest();
                autoFitterOptions.AutoFitMergedCells = true;
                autoFitterOptions.IgnoreHidden       = true;
                autoFitterOptions.OnlyAuto           = false;

                cellsService.Workbook.AutofitWorkbookRows(name, 1, 50, false, autoFitterOptions, Utils.CloudStorage_Output_Folder);

                //storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/cells-sample.xlsx", Utils.Local_Output_Path + "/cells-sample.xlsx");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public void Cells_WorksheetColumns_Tests()
        {
            try
            {
                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/cells-sample.xlsx", Utils.CloudStorage_Output_Folder + "/cells-sample.xlsx");

                WorksheetColumnsResponse worksheetColumnsResponse = cellsService.WorksheetColumns.ReadWorksheetColumnsInfo(name, "sheet1", Utils.CloudStorage_Output_Folder);
                WorksheetColumnResponse  worksheetColumnResponse  = cellsService.WorksheetColumns.SetWorksheetColumnWidth(name, "sheet1", 1, 500, Utils.CloudStorage_Output_Folder);
                WorksheetColumnResponse  worksheetColumnResponse2 = cellsService.WorksheetColumns.ReadWorksheetColumnDataByColumnIndex(name, "sheet1", 1, Utils.CloudStorage_Output_Folder);

                cellsService.WorksheetColumns.HideWorksheetColumns(name, "sheet1", 0, 5, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.UnhideWorksheetColumns(name, "sheet1", 0, 5, 150, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.GroupWorksheetColumns(name, "sheet1", 0, 3, true, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.UngroupWorksheetColumns(name, "sheet1", 0, 3, Utils.CloudStorage_Output_Folder);

                cellsService.WorksheetColumns.ClearCellsContents(name, "sheet1", "A1:F5", 1, 1, 5, 5, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.ClearCellsFormats(name, "sheet1", "A1:F5", 1, 1, 5, 5, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.MergeCells(name, "sheet1", 0, 0, 5, 5, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.UnmergeCells(name, "sheet1", 0, 0, 5, 5, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.CopyWorksheetColumns(name, "sheet1", 1, 2, 2, "sheet1", Utils.CloudStorage_Output_Folder);

                WorksheetRowResponse WorksheetRowResponse = cellsService.WorksheetColumns.ReadWorksheetRowDataByRowIndex(name, "sheet1", 0, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.DeleteWorksheetRow(name, "sheet1", 1, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.InsertNewWorksheetRow(name, "sheet1", 2, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.UpdateWorksheetRow(name, "sheet1", 2, 120, Utils.CloudStorage_Output_Folder);

                cellsService.WorksheetColumns.HideWorksheetRows(name, "sheet1", 1, 2, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.UnhideWorksheetRows(name, "sheet1", 1, 5, 120, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.GroupWorksheetRows(name, "sheet1", 1, 3, true, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.UngroupWorksheetRows(name, "sheet1", 1, 4, true, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.CopyWorksheetRows(name, "sheet1", 1, 5, 5, "sheet1", Utils.CloudStorage_Output_Folder);

                CellsResponse         cellsResponse         = cellsService.WorksheetColumns.GetCellsInfo(name, "sheet1", 1, 10, Utils.CloudStorage_Output_Folder);
                WorkbookCellResponse  workbookCellResponse1 = cellsService.WorksheetColumns.ReadCellDataByCellName(name, "sheet1", "C4", Utils.CloudStorage_Output_Folder);
                WorksheetRowsResponse worksheetRowsResponse = cellsService.WorksheetColumns.ReadWorksheetRowsInfo(name, "sheet1", Utils.CloudStorage_Output_Folder);

                cellsService.WorksheetColumns.SetHtmlstringValueIntoCell(name, "sheet1", "A1", Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.DeleteSeveralWorksheetRows(name, "sheet1", 1, 10, false, Utils.CloudStorage_Output_Folder);

                cellsService.WorksheetColumns.CopyCellIntoCell(name, "sheet1", "A1", "sheet1", "C4", 5, 3, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.InsertSeveralNewWorksheetRows(name, "sheet1", 1, 10, true, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.SetCellRangeValue(name, "sheet1", "A1", "Aspose", "string", Utils.CloudStorage_Output_Folder);
                WorkbookCellResponse     workbookCellResponse      = cellsService.WorksheetColumns.SetCellValue(name, "sheet1", "A1", "Aspose", "string", string.Empty, Utils.CloudStorage_Output_Folder);
                WorksheetColumnsResponse worksheetColumnsResponse3 = cellsService.WorksheetColumns.InsertWorksheetColumns(name, "sheet1", 1, 5, false, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.DeleteWorksheetColumns(name, "sheet1", 1, 5, false, Utils.CloudStorage_Output_Folder);

                WorkbookStyleResponse workbookStyleResponse = cellsService.WorksheetColumns.ReadCellStyleInfo(name, "sheet1", "B5", Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.UpdateCellStyle(name, "sheet1", "A1", workbookStyleResponse.Style, Utils.CloudStorage_Output_Folder);
                cellsService.WorksheetColumns.UpdateCellRangeStyle(name, "sheet1", "A1:F5", workbookStyleResponse.Style, Utils.CloudStorage_Output_Folder);

                storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/cells-sample.xlsx", Utils.Local_Output_Path + "/cells-sample.xlsx");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
示例#3
0
        static void Main()
        {
            string dataDir = Common.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            string input = "sample1.xlsx";

            Common.StorageService.File.UploadFile(dataDir + input, input, storage: Common.STORAGE);

            WorkbookStyleResponse apiResponse = Common.CellsService.WorksheetColumns.ReadCellStyleInfo(input, "Sheet1", "A1", Common.FOLDER, storage: Common.STORAGE);

            Console.WriteLine(" Response Text Direction: " + apiResponse.Style.TextDirection.ToString());
        }
        public void Cells_PivotTable_Tests()
        {
            try
            {
                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/cells-sample.xlsx", Utils.CloudStorage_Output_Folder + "/cells-sample.xlsx");

                string name = "cells-sample.xlsx";

                PivotTablesResponse pivotTablesResponse = cellsService.PivotTable.GetWorksheetPivottablesInfo(name, "sheet6", Utils.CloudStorage_Output_Folder);
                PivotTableResponse  pivotTableResponse  = cellsService.PivotTable.GetWorksheetPivottableInfoByIndex(name, "sheet6", 0, Utils.CloudStorage_Output_Folder);
                cellsService.PivotTable.DeleteWorksheetPivotTableByIndex(name, "sheet6", 0, Utils.CloudStorage_Output_Folder);
                cellsService.PivotTable.DeleteWorksheetPivotTables(name, "sheet6", Utils.CloudStorage_Output_Folder);

                CreatePivotTableRequest createPivotTableRequest = new CreatePivotTableRequest();
                createPivotTableRequest.Name          = "Test Pivot Table";
                createPivotTableRequest.SourceData    = "A1:C7";
                createPivotTableRequest.DestCellName  = "H10";
                createPivotTableRequest.UseSameSource = true;

                createPivotTableRequest.PivotFieldRows = new List <int>();
                createPivotTableRequest.PivotFieldRows.Add(1);

                createPivotTableRequest.PivotFieldColumns = new List <int>();
                createPivotTableRequest.PivotFieldColumns.Add(1);

                createPivotTableRequest.PivotFieldData = new List <int>();
                createPivotTableRequest.PivotFieldData.Add(1);

                cellsService.PivotTable.AddAPivotTableIntoWorksheet(name, "sheet7", createPivotTableRequest, Utils.CloudStorage_Output_Folder);

                PivotTableFieldRequest pivotTableFieldRequest = new PivotTableFieldRequest();
                pivotTableFieldRequest.Data = new List <int>();
                pivotTableFieldRequest.Data.Add(1);
                pivotTableFieldRequest.Data.Add(2);
                cellsService.PivotTable.AddPivotFieldIntoIntoPivotTable(name, "sheet6", 0, "Row", pivotTableFieldRequest, Utils.CloudStorage_Output_Folder);

                WorkbookStyleResponse workbookStyleResponse = cellsService.WorksheetColumns.ReadCellStyleInfo(name, "sheet6", "A8", Utils.CloudStorage_Output_Folder);

                cellsService.PivotTable.UpdateCellStyleForPivotTable(name, "sheet6", 0, 1, 1, workbookStyleResponse.Style, Utils.CloudStorage_Output_Folder);

                cellsService.PivotTable.UpdateStyleForPivotTable(name, "sheet6", 0, workbookStyleResponse.Style, Utils.CloudStorage_Output_Folder);

                storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/cells-sample.xlsx", "d:\\cells-sample.xlsx");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }