public void TestProtectDocument() { string remoteFileName = "TestProtectDocument.docx"; this.UploadFileToStorage( remoteDataFolder + "/" + remoteFileName, null, null, File.ReadAllBytes(LocalTestDataFolder + localFile) ); var request = new ProtectDocumentRequest( name: remoteFileName, protectionRequest: new ProtectionRequest() { Password = "******", ProtectionType = "ReadOnly" }, folder: remoteDataFolder, destFileName: BaseTestOutPath + "/" + remoteFileName ); var actual = this.WordsApi.ProtectDocument(request); Assert.NotNull(actual.ProtectionData); Assert.AreEqual("ReadOnly", actual.ProtectionData.ProtectionType); }
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); } }
static void Main() { string dataDir = Common.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); string input = "sample1.xlsx"; string output = "ouput.xlsx"; Common.StorageService.File.UploadFile(dataDir + input, input, storage: Common.STORAGE); ProtectDocumentRequest protectDocumentRequest = new ProtectDocumentRequest(); protectDocumentRequest.Password = "******"; Common.CellsService.Workbook.UnprotectDocumentFromChanges(input, Common.FOLDER, protectDocumentRequest, storage: Common.STORAGE); Common.StorageService.File.DownloadFile(input, dataDir + output, storage: Common.STORAGE); }