C# Класс OfficeOpenXml.ExcelPackage

Represents an Excel 2007 XLSX file package. Opens the file and provides access to all the components (workbook, worksheets, properties etc.).
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
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.

Описание методов

Dispose() публичный Метод

Closes the package.
public Dispose ( ) : void
Результат void

ExcelPackage() публичный Метод

Create a new instance of the ExcelPackage. Output is accessed through the Stream property.
public ExcelPackage ( ) : System
Результат System

ExcelPackage() публичный Метод

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.
Результат System

ExcelPackage() публичный Метод

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
Результат System

ExcelPackage() публичный Метод

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
Результат System

ExcelPackage() публичный Метод

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
Результат System

ExcelPackage() публичный Метод

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
Результат System

ExcelPackage() публичный Метод

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
Результат System

ExcelPackage() публичный Метод

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
Результат System

ExcelPackage() публичный Метод

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
Результат System

ExcelPackage() публичный Метод

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
Результат System

ExcelPackage() публичный Метод

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
Результат System

GetAsByteArray() публичный Метод

Saves and returns the Excel files as a bytearray. Note that the package is closed upon save
public GetAsByteArray ( ) : byte[]
Результат byte[]

GetAsByteArray() публичный Метод

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.
Результат byte[]

Load() публичный Метод

Loads the specified package data from a stream.
public Load ( Stream input ) : void
input Stream The input.
Результат void

Load() публичный Метод

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
Результат void

Save() публичный Метод

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
Результат void

Save() публичный Метод

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.
Результат void

SaveAs() публичный Метод

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
Результат void

SaveAs() публичный Метод

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.
Результат void

SaveAs() публичный Метод

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
Результат void

SaveAs() публичный Метод

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.
Результат void