Esempio n. 1
0
        public static void CreateEncryptedFile()
        {
            using (OfficeCryptoStream stream = OfficeCryptoStream.Create("a.xlsx"))
            {
                DoStuff(stream);

                // Set or change the password anytime before the save.
                // Set to null to save as plaintext.
                stream.Password = "******";

                stream.Save();
            }
        }
Esempio n. 2
0
 void CreateTestWorkbook(String password)
 {
     using (OfficeCryptoStream s = OfficeCryptoStream.Create(TestFile))
     {
         s.Password = password;
         using (ExcelPackage p = new ExcelPackage(s))
         {
             ExcelWorksheet ws = p.Workbook.Worksheets["Test"];
             if (ws == null)
             {
                 ws = p.Workbook.Worksheets.Add("Test");
             }
             ws.Cell(1, 1).Value = "Test Cell";
             p.Save();
         }
         s.Save();
     }
 }