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);
            }
        }
Beispiel #2
0
        static void Main()
        {
            string dataDir = Common.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            string input = "sample1.xlsx";
            string text  = "aspose";

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

            CellsTextItemsResponse apiResponse = Common.CellsService.Workbook.SearchText(input, text, Common.FOLDER, storage: Common.STORAGE);

            Console.WriteLine(" Response Type: " + apiResponse.TextItems.GetType().ToString());
        }
        public void Cells_Worksheets_Tests()
        {
            try
            {
                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/cells-sample.xlsx", Utils.CloudStorage_Output_Folder + "/cells-sample.xlsx");

                WorksheetsResponse WorksheetsResponse = cellsService.Worksheets.ReadWorksheetsInfo(name, Utils.CloudStorage_Output_Folder);
                WorksheetResponse  ReadWorksheetInfo  = cellsService.Worksheets.ReadWorksheetInfo(name, "sheet2", Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.ExportWorksheet(name, "sheet1", WorksheetExportFormat.Gif, 0, 0, Utils.CloudStorage_Output_Folder, Utils.Local_Output_Path + "cells_worksheet_gif.gif");

                cellsService.Worksheets.AddNewWorksheet(name, "sheetZ", Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.DeleteWorksheet(name, "sheetZ", Utils.CloudStorage_Output_Folder);

                ReadWorksheetInfo.Worksheet.IsSelected = true;
                WorksheetResponse WorksheetResponse = cellsService.Worksheets.UpdateWorksheetProperty(name, "sheet2", ReadWorksheetInfo.Worksheet, Utils.CloudStorage_Output_Folder);

                WorksheetResponse WorksheetResponse2 = cellsService.Worksheets.ChangeWorksheetVisibility(name, "sheet1", false, Utils.CloudStorage_Output_Folder);
                WorksheetResponse WorksheetResponse3 = cellsService.Worksheets.ChangeWorksheetVisibility(name, "sheet1", true, Utils.CloudStorage_Output_Folder);

                CellsMoveWorksheetRequest cellsMoveWorksheetRequest = new CellsMoveWorksheetRequest();
                cellsMoveWorksheetRequest.DestinationWorksheet = "sheet3";
                cellsMoveWorksheetRequest.Position             = 3;

                cellsService.Worksheets.MoveWorksheet(name, "sheet1", cellsMoveWorksheetRequest, Utils.CloudStorage_Output_Folder);

                CellsProtectParameter cellsProtectParameter = new CellsProtectParameter(CellsProtectionType.All);
                cellsProtectParameter.Password = "******";
                cellsService.Worksheets.ProtectWorksheet(name, "sheet1", cellsProtectParameter, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.UnprotectWorksheet(name, "sheet1", cellsProtectParameter, Utils.CloudStorage_Output_Folder);

                CellsTextItemsResponse CellsTextItemsResponse = cellsService.Worksheets.GetWorksheetTextItems(name, "sheet1", Utils.CloudStorage_Output_Folder);

                CellsCommentRequest cellsCommentRequest = new CellsCommentRequest();
                cellsCommentRequest.Note      = "Aspose.Cells for .NET";
                cellsCommentRequest.IsVisible = true;
                cellsCommentRequest.CellName  = "A1";
                cellsCommentRequest.Width     = 100;
                cellsCommentRequest.Height    = 50;

                cellsService.Worksheets.AddWorksheetsCellComment(name, "sheet1", "A1", cellsCommentRequest, Utils.CloudStorage_Output_Folder);

                CellsCommentsResponse CellsCommentsResponse = cellsService.Worksheets.GetWorksheetComments(name, "sheet1", Utils.CloudStorage_Output_Folder);
                CellsCommentResponse  CellsCommentResponse  = cellsService.Worksheets.GetWorksheetCommentByCellName(name, "sheet1", "A1", Utils.CloudStorage_Output_Folder);

                cellsCommentRequest.Author = "Aspose";
                cellsService.Worksheets.UpdateWorksheetsCellComment(name, "sheet1", "A1", cellsCommentRequest, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.DeleteWorksheetsCellComment(name, "sheet1", "A1", Utils.CloudStorage_Output_Folder);

                MergedCellsResponse MergedCellsResponse = cellsService.Worksheets.GetWorksheetMergedCells(name, "sheet1", Utils.CloudStorage_Output_Folder);
                MergedCellResponse  MergedCellResponse  = cellsService.Worksheets.GetWorksheetMergedCellByItsIndex(name, "sheet1", 0, Utils.CloudStorage_Output_Folder);

                CellsForumulaValueResponse    CellsForumulaValueResponse    = cellsService.Worksheets.CalculateFormulaValue(name, "sheet1", "D5*E5", Utils.CloudStorage_Output_Folder);
                CellsTextItemsResponse        CellsTextItemsResponse2       = cellsService.Worksheets.SearchText(name, "sheet1", "Student1", Utils.CloudStorage_Output_Folder);
                CellsWorksheetMatchesResponse CellsWorksheetMatchesResponse = cellsService.Worksheets.ReplaceText(name, "sheet1", "Student", "Employee", Utils.CloudStorage_Output_Folder);

                CellsDataSorterRequest dataSorter = new CellsDataSorterRequest();
                dataSorter.CaseSensitive = true;
                dataSorter.HasHeaders    = true;

                CellsKeyList cellsKeyList = new CellsKeyList();
                cellsKeyList.Key       = 1;
                cellsKeyList.SortOrder = "DESCENDING";

                dataSorter.KeyList = new List <CellsKeyList>();
                dataSorter.KeyList.Add(cellsKeyList);

                cellsService.Worksheets.SortWorksheetRange(name, "sheet1", "B4:F19", dataSorter, Utils.CloudStorage_Output_Folder);

                CellsAutoFitterOptionsRequest autoFitterOptions = new CellsAutoFitterOptionsRequest();
                autoFitterOptions.OnlyAuto = true;
                cellsService.Worksheets.AutofitWorksheetRows(name, "sheet1", 1, 100, true, autoFitterOptions, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.SetWorksheetBackgroundImage(name, "sheet1", Utils.Local_Input_Path + "signature.jpg", Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.DeleteWorksheetBackgroundImage(name, "sheet1", Utils.CloudStorage_Output_Folder);

                cellsService.Worksheets.SetFreezePanes(name, "sheet1", 4, 1, 1, 1, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.UnfreezePanes(name, "sheet1", 4, 1, 1, 1, Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.CopyWorksheet(name, "sheetZ", "sheet1", Utils.CloudStorage_Output_Folder);
                cellsService.Worksheets.RenameWorksheet(name, "sheetZ", "sheetRenamed", 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);
            }
        }