打开加密excel 和 自定义c#dll目录
POIFSFileSystem pfs = newPOIFSFileSystem(POIDataSamples.getPOIFSInstance().openResourceAsStream("yourexcelfile.xlsx"));
EncryptionInfo encInfo = new EncryptionInfo(pfs);
Decryptor decryptor = new Decryptor(encInfo);
decryptor.verifyPassword("ABCXYZ");
XSSFWorkbook wb = new XSSFWorkbook(decryptor.getDataStream(pfs));
打开加密excel。
自定义dll目录
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); Application.Run(new Form1()); } static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"DLL\"); path = System.IO.Path.Combine(path, args.Name.Split(',')[0]); path = String.Format(@"{0}.dll", path); return System.Reflection.Assembly.LoadFrom(path); }