本文整理汇总了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();
}
示例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");
}
示例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");
}
示例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);
}
示例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");
}
示例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
}