예제 #1
0
        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_Protected_Test_Book.xls";
            String storage  = "";
            String folder   = "";
            WorkbookProtectionRequest body = new WorkbookProtectionRequest();

            body.Password       = "******";
            body.ProtectionType = "All";

            try
            {
                // Upload source file to aspose cloud storage
                storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName));

                // Invoke Aspose.Words Cloud SDK API to unprotect workbook
                SaaSposeResponse apiResponse = cellsApi.DeleteUnProtectDocument(fileName, storage, folder, body);

                if (apiResponse != null && apiResponse.Status.Equals("OK"))
                {
                    Console.WriteLine("Workbook is now un-protected");
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }
예제 #2
0
        public void CellsWorkbookDeleteUnProtectDocumentTest()
        {
            string name = "Book1.xlsx";
            WorkbookProtectionRequest protection = new WorkbookProtectionRequest();

            protection.Password       = "******";
            protection.ProtectionType = "All";
            string folder = null;

            new Config().UpdateDataFile(folder, name);
            var response = instance.CellsWorkbookDeleteUnprotectDocument(name, protection, folder);

            Console.WriteLine(response);
        }
        public void CellsWorkbookDeleteUnProtectDocumentTest()
        {
            // TODO uncomment below to test the method and replace null with proper value
            string name = BOOK1;
            WorkbookProtectionRequest protection = new WorkbookProtectionRequest();

            protection.Password       = "******";
            protection.ProtectionType = "All";
            string folder = TEMPFOLDER;

            UpdateDataFile(instance, folder, name);
            var response = instance.CellsWorkbookDeleteUnprotectDocument(name, protection, folder);

            Assert.IsInstanceOf <CellsCloudResponse>(response, "response is CellsCloudResponse");
            Assert.AreEqual(response.Code, 200);
        }