In .Net Package Class act as a container that holds multiple types of objects in the hierarchical manner. Each object in hierarchy of Package is known as its Part. Essentially, this Class eases the access of a package and its parts in more efficient and useful manner. .Net 3.0 introduced a new assembly named windowsbase.dll which contains the System.IO.Packaging Namespace. This assembly is required for accessing the functionality of Packaging Classes. You may need to reference the assembly in Visual Studio before adding the namespace in your Asp.Net page. The default location is C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0 Once reference is added you can use open method of Package class to open a package. Given below is the method to open a XLSX Document using the Package class open method.
Public Function OpenPackage(ByVal XLSXPath As String) As Boolean Dim oXlPackage As Package If XLSXPath <> "" Then oXlPackage = Package.Open(oPath, FileMode.Open, FileAccess.ReadWrite) End If End Function
Package is a abstract class, ZipPackage is derived from Package that is used by the open method by default. Its mean ZipPackage is default type of Package and this is used by open method.
Leave your comment
Remember Me
Post Timeline Calendar with Post
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.