当前位置: 首页>>代码示例>>C#>>正文


C# Workbook.SetEncryptionOptions方法代码示例

本文整理汇总了C#中Workbook.SetEncryptionOptions方法的典型用法代码示例。如果您正苦于以下问题:C# Workbook.SetEncryptionOptions方法的具体用法?C# Workbook.SetEncryptionOptions怎么用?C# Workbook.SetEncryptionOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Workbook的用法示例。


在下文中一共展示了Workbook.SetEncryptionOptions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateStaticReport

    public void CreateStaticReport()
    {
        //Open template.
        string path = System.Web.HttpContext.Current.Server.MapPath("~");
        path = path.Substring(0, path.LastIndexOf("\\"));
        path += @"\designer\book1.xls";

        //Instantiate a new Workbook object.
        Workbook workbook = new Workbook(path);

        //Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
        workbook.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);

        //Use this line if you want to specify XOR Encrytion type.
        //workbook.SetEncryptionOptions(EncryptionType.XOR, 40);

        //Password protect the file.
        workbook.Settings.Password = "007";

        if (ddlFileVersion.SelectedItem.Value == "XLS")
        {
            ////Save file and send to client browser using selected format
            workbook.Save(HttpContext.Current.Response, "EncryptedBook.xls", ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003));
        }
        else
        {
            workbook.Save(HttpContext.Current.Response, "EncryptedBook.xlsx", ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsx));
        }

        //end response to avoid unneeded html
        HttpContext.Current.Response.End();
    }
开发者ID:babar-raza,项目名称:Aspose_Cells_NET,代码行数:32,代码来源:encrypt-an-excel-file.aspx.cs

示例2: Main

        static void Main(string[] args)
        {
            //Instantiate a Workbook object.
            //Open an excel file.
            Workbook workbook = new Workbook("Book1.xls");

            //Specify XOR encryption type.
            workbook.SetEncryptionOptions(EncryptionType.XOR, 40);

            //Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
            workbook.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);

            //Password protect the file.
            workbook.Settings.Password = "1234";

            //Save the excel file.
            workbook.Save("encryptedBook1.xls");
        }
开发者ID:assadvirgo,项目名称:Aspose_Cells_NET,代码行数:18,代码来源:Program.cs

示例3: Main

        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            //Instantiate a Workbook object.
            //Open an excel file.
            Workbook workbook = new Workbook(dataDir + "Book1.xls");

            //Specify XOR encryption type.
            workbook.SetEncryptionOptions(EncryptionType.XOR, 40);

            //Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
            workbook.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);

            //Password protect the file.
            workbook.Settings.Password = "1234";

            //Save the excel file.
            workbook.Save(dataDir + "encryptedBook1.xls");
        }
开发者ID:assadvirgo,项目名称:Aspose_Cells_NET,代码行数:21,代码来源:EncryptingFiles.cs

示例4: Main

        static void Main(string[] args)
        {
            string FilePath = @"..\..\..\Sample Files\";
            string srcFileName = FilePath + "Encrypting Excel Files.xlsx";
            string destFileName = FilePath + "Result Encrypting Excel Files.xlsx";
            
            //Open an excel file.
            Workbook workbook = new Workbook(srcFileName);

            //Specify XOR encryption type.
            workbook.SetEncryptionOptions(EncryptionType.XOR, 40);

            //Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
            workbook.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);

            //Password protect the file.
            workbook.Settings.Password = "1234";

            //Save the excel file.
            workbook.Save(destFileName);
        }
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:21,代码来源:Program.cs

示例5: Main

        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //Instantiate a Workbook object.
            //Open an excel file.
            Workbook workbook = new Workbook(dataDir + "Book1.xls");

            //Specify XOR encryption type.
            workbook.SetEncryptionOptions(EncryptionType.XOR, 40);

            //Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
            workbook.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);

            //Password protect the file.
            workbook.Settings.Password = "1234";

            //Save the excel file.
            workbook.Save(dataDir + "encryptedBook1.xls");
        }
开发者ID:mmunchandersen,项目名称:Aspose_Cells_NET,代码行数:21,代码来源:Program.cs

示例6: Run

        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Instantiate a Workbook object.
            // Open an excel file.
            Workbook workbook = new Workbook(dataDir+ "Book1.xlsx");

            // Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
            workbook.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);

            // Password protect the file.
            workbook.Settings.Password = "1234";

            // Save the Excel file.
            workbook.Save(dataDir+ "encryptedBook1.out.xls");
            // ExEnd:1
        }
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:20,代码来源:SettingStrongEncryptionType.cs


注:本文中的Workbook.SetEncryptionOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。