C# Class OfficeOpenXml.ExcelPackage

Represents an Excel 2007 XLSX file package. Opens the file and provides access to all the components (workbook, worksheets, properties etc.).
Inheritance: IDisposable
Datei anzeigen Open project: ylatuya/EPPlus Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Closes the package.

ExcelPackage ( ) : System

Create a new instance of the ExcelPackage. Output is accessed through the Stream property.

ExcelPackage ( FileInfo newFile ) : System

Create a new instance of the ExcelPackage class based on a existing file or creates a new file.

ExcelPackage ( FileInfo newFile, FileInfo template ) : System

Create a new instance of the ExcelPackage class based on a existing template. If newFile exists, it will be overwritten when the Save method is called

ExcelPackage ( FileInfo newFile, FileInfo template, string password ) : System
ExcelPackage ( FileInfo template, bool useStream ) : System

Create a new instance of the ExcelPackage class based on a existing template.

ExcelPackage ( FileInfo template, bool useStream, string password ) : System

Create a new instance of the ExcelPackage class based on a existing template.

ExcelPackage ( FileInfo newFile, string password ) : System

Create a new instance of the ExcelPackage class based on a existing file or creates a new file.

ExcelPackage ( Stream newStream ) : System

Create a new instance of the ExcelPackage class based on a stream

ExcelPackage ( Stream newStream, Stream templateStream ) : System

Create a new instance of the ExcelPackage class based on a stream

ExcelPackage ( Stream newStream, Stream templateStream, string Password ) : System

Create a new instance of the ExcelPackage class based on a stream

ExcelPackage ( Stream newStream, string Password ) : System

Create a new instance of the ExcelPackage class based on a stream

GetAsByteArray ( ) : byte[]

Saves and returns the Excel files as a bytearray. Note that the package is closed upon save

GetAsByteArray ( string password ) : byte[]

Saves and returns the Excel files as a bytearray Note that the package is closed upon save

Load ( Stream input ) : void

Loads the specified package data from a stream.

Load ( Stream input, string Password ) : void

Loads the specified package data from a stream.

Save ( ) : void

Saves all the components back into the package. This method recursively calls the Save method on all sub-components. We close the package after the save is done.

Save ( string password ) : void

Saves all the components back into the package. This method recursively calls the Save method on all sub-components. The package is closed after it has been saved

SaveAs ( FileInfo file ) : void

Saves the workbook to a new file The package is closed after it has been saved

SaveAs ( FileInfo file, string password ) : void

Saves the workbook to a new file The package is closed after it has been saved

SaveAs ( Stream OutputStream ) : void

Copies the Package to the Outstream The package is closed after it has been saved

SaveAs ( Stream OutputStream, string password ) : void

Copies the Package to the Outstream The package is closed after it has been saved

Private Methods

Method Description
AddImage ( byte image ) : ImageInfo
AddImage ( byte image, Uri uri, string contentType ) : ImageInfo
ConstructNewFile ( Stream stream, string password ) : void
CopyStream ( Stream inputStream, Stream &outputStream ) : void

Copies the input stream to the output stream.

CreateBlankWb ( ) : void
CreateDefaultNSM ( ) : XmlNamespaceManager
CreateFromTemplate ( FileInfo template, string password ) : void

Create a new file from a template

GetAsByteArray ( bool save ) : byte[]
GetImageInfo ( byte image ) : ImageInfo
GetNewUri ( Package package, string sUri ) : Uri
GetXmlFromUri ( Uri uri ) : XmlDocument

Get the XmlDocument from an URI

Init ( ) : void

Init values here

Load ( Stream input, Stream output, string Password ) : void

ReadFile ( ) : void
SavePart ( Uri uri, XmlDocument xmlDoc ) : void

Saves the XmlDocument into the package at the specified Uri.

SaveWorkbook ( Uri uri, XmlDocument xmlDoc ) : void

Saves the XmlDocument into the package at the specified Uri.

Method Details

Dispose() public method

Closes the package.
public Dispose ( ) : void
return void

ExcelPackage() public method

Create a new instance of the ExcelPackage. Output is accessed through the Stream property.
public ExcelPackage ( ) : System
return System

ExcelPackage() public method

Create a new instance of the ExcelPackage class based on a existing file or creates a new file.
public ExcelPackage ( FileInfo newFile ) : System
newFile System.IO.FileInfo If newFile exists, it is opened. Otherwise it is created from scratch.
return System

ExcelPackage() public method

Create a new instance of the ExcelPackage class based on a existing template. If newFile exists, it will be overwritten when the Save method is called
public ExcelPackage ( FileInfo newFile, FileInfo template ) : System
newFile System.IO.FileInfo The name of the Excel file to be created
template System.IO.FileInfo The name of the Excel template to use as the basis of the new Excel file
return System

ExcelPackage() public method

public ExcelPackage ( FileInfo newFile, FileInfo template, string password ) : System
newFile System.IO.FileInfo The name of the Excel file to be created
template System.IO.FileInfo The name of the Excel template to use as the basis of the new Excel file
password string Password to decrypted the template
return System

ExcelPackage() public method

Create a new instance of the ExcelPackage class based on a existing template.
public ExcelPackage ( FileInfo template, bool useStream ) : System
template System.IO.FileInfo The name of the Excel template to use as the basis of the new Excel file
useStream bool if true use a stream. If false create a file in the temp dir with a random name
return System

ExcelPackage() public method

Create a new instance of the ExcelPackage class based on a existing template.
public ExcelPackage ( FileInfo template, bool useStream, string password ) : System
template System.IO.FileInfo The name of the Excel template to use as the basis of the new Excel file
useStream bool if true use a stream. If false create a file in the temp dir with a random name
password string Password to decrypted the template
return System

ExcelPackage() public method

Create a new instance of the ExcelPackage class based on a existing file or creates a new file.
public ExcelPackage ( FileInfo newFile, string password ) : System
newFile System.IO.FileInfo If newFile exists, it is opened. Otherwise it is created from scratch.
password string Password for an encrypted package
return System

ExcelPackage() public method

Create a new instance of the ExcelPackage class based on a stream
public ExcelPackage ( Stream newStream ) : System
newStream Stream The stream object can be empty or contain a package. The stream must be Read/Write
return System

ExcelPackage() public method

Create a new instance of the ExcelPackage class based on a stream
public ExcelPackage ( Stream newStream, Stream templateStream ) : System
newStream Stream The output stream. Must be an empty read/write stream.
templateStream Stream This stream is copied to the output stream at load
return System

ExcelPackage() public method

Create a new instance of the ExcelPackage class based on a stream
public ExcelPackage ( Stream newStream, Stream templateStream, string Password ) : System
newStream Stream The output stream. Must be an empty read/write stream.
templateStream Stream This stream is copied to the output stream at load
Password string Password to decrypted the template
return System

ExcelPackage() public method

Create a new instance of the ExcelPackage class based on a stream
public ExcelPackage ( Stream newStream, string Password ) : System
newStream Stream The stream object can be empty or contain a package. The stream must be Read/Write
Password string The password to decrypt the document
return System

GetAsByteArray() public method

Saves and returns the Excel files as a bytearray. Note that the package is closed upon save
public GetAsByteArray ( ) : byte[]
return byte[]

GetAsByteArray() public method

Saves and returns the Excel files as a bytearray Note that the package is closed upon save
public GetAsByteArray ( string password ) : byte[]
password string The password to encrypt the workbook with. /// This parameter overrides the Encryption.Password.
return byte[]

Load() public method

Loads the specified package data from a stream.
public Load ( Stream input ) : void
input Stream The input.
return void

Load() public method

Loads the specified package data from a stream.
public Load ( Stream input, string Password ) : void
input Stream The input.
Password string The password to decrypt the document
return void

Save() public method

Saves all the components back into the package. This method recursively calls the Save method on all sub-components. We close the package after the save is done.
public Save ( ) : void
return void

Save() public method

Saves all the components back into the package. This method recursively calls the Save method on all sub-components. The package is closed after it has been saved
public Save ( string password ) : void
password string The password to encrypt the workbook with. /// This parameter overrides the Workbook.Encryption.Password.
return void

SaveAs() public method

Saves the workbook to a new file The package is closed after it has been saved
public SaveAs ( FileInfo file ) : void
file System.IO.FileInfo
return void

SaveAs() public method

Saves the workbook to a new file The package is closed after it has been saved
public SaveAs ( FileInfo file, string password ) : void
file System.IO.FileInfo The file
password string The password to encrypt the workbook with. /// This parameter overrides the Encryption.Password.
return void

SaveAs() public method

Copies the Package to the Outstream The package is closed after it has been saved
public SaveAs ( Stream OutputStream ) : void
OutputStream Stream The stream to copy the package to
return void

SaveAs() public method

Copies the Package to the Outstream The package is closed after it has been saved
public SaveAs ( Stream OutputStream, string password ) : void
OutputStream Stream The stream to copy the package to
password string The password to encrypt the workbook with. /// This parameter overrides the Encryption.Password.
return void