Info: How to open a Package

September 17th, 2007 | Tags: ,

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.





Share and Enjoy:
  • Twitter
  • Digg
  • del.icio.us
  • StumbleUpon
  • Google Bookmarks
  • Technorati
  • Facebook
  • DotNetKicks
  • email
  • Print
  • NewsVine
  • Reddit
  • RSS
No comments yet.