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 static void Run() { // ExStart:1 CellsApi cellsApi = new CellsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "Sample_Test_Book.xls"; String storage = ""; String folder = ""; WorkbookEncryptionRequest body = new WorkbookEncryptionRequest(); body.EncryptionType = "XOR"; body.Password = "******"; body.KeyLength = 128; try { // Upload source file to aspose cloud storage storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Cells Cloud SDK API to encrypt excel workbook SaaSposeResponse apiResponse = cellsApi.PostEncryptDocument(fileName, storage, folder, body); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("File is Encrypted"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public void CellsWorkbookDeleteDecryptDocumentTest() { string name = "Book1.xlsx"; WorkbookEncryptionRequest encryption = new WorkbookEncryptionRequest(); encryption.Password = "******"; encryption.KeyLength = 128; encryption.EncryptionType = "XOR"; string folder = null; new Config().UpdateDataFile(folder, name); var response = instance.CellsWorkbookDeleteDecryptDocument(name, encryption, folder); Console.WriteLine(response); }
public void CellsWorkbookDeleteDecryptDocumentTest() { // TODO uncomment below to test the method and replace null with proper value string name = BOOK1; WorkbookEncryptionRequest encryption = new WorkbookEncryptionRequest(); encryption.Password = "******"; encryption.KeyLength = 128; encryption.EncryptionType = "XOR"; string folder = TEMPFOLDER; UpdateDataFile(instance, folder, name); var response = instance.CellsWorkbookDeleteDecryptDocument(name, encryption, folder); Assert.IsInstanceOf <CellsCloudResponse>(response, "response is CellsCloudResponse"); Assert.AreEqual(response.Code, 200); }
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); CellsProtectParameter cellsProtectParameter = new CellsProtectParameter(CellsProtectionType.All); cellsProtectParameter.Password = "******"; WorkbookEncryptionRequest workbookEncryptionRequest = new WorkbookEncryptionRequest(WorkbookEncryptionType.XOR, 128, "Aspose"); Common.CellsService.Workbook.EncriptDocument(input, Common.FOLDER, workbookEncryptionRequest, storage: Common.STORAGE); Common.StorageService.File.DownloadFile(input, dataDir + output, storage: Common.STORAGE); }
public void CellsWorksheetsPutWorkSheetCommentTest() { string name = "Book1.xlsx"; string sheetName = "SHEET1"; string cellName = "C1"; Comment comment = new Comment(); comment.Author = "roy"; WorkbookEncryptionRequest encryption = new WorkbookEncryptionRequest(); encryption.Password = "******"; encryption.KeyLength = 128; encryption.EncryptionType = "XOR"; string folder = null; new Config().UpdateDataFile(folder, name); var response = instance.CellsWorksheetsPutWorksheetComment(name, sheetName, cellName, comment, folder); Console.WriteLine(response); }
public void CellsWorksheetsPutWorkSheetCommentTest() { // TODO uncomment below to test the method and replace null with proper value string name = BOOK1; string sheetName = SHEET1; string cellName = "C1"; Comment comment = new Comment(); comment.Author = "roy"; WorkbookEncryptionRequest encryption = new WorkbookEncryptionRequest(); encryption.Password = "******"; encryption.KeyLength = 128; encryption.EncryptionType = "XOR"; string folder = TEMPFOLDER; UpdateDataFile(instance, folder, name); var response = instance.CellsWorksheetsPutWorksheetComment(name, sheetName, cellName, comment, folder); Assert.IsInstanceOf <CommentResponse>(response, "response is CommentResponse"); Assert.AreEqual(response.Code, 200); }