GetAsByteArray Method (String)

Office Open XML

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

Namespace:  OfficeOpenXml
Assembly:  EPPlus (in EPPlus.dll) Version: 3.0.0.1 (3.0.0.1)

Syntax

C#
public byte[] GetAsByteArray(
	string password
)
Visual Basic (Declaration)
Public Function GetAsByteArray ( _
	password As String _
) As Byte()
Visual C++
public:
array<unsigned char>^ GetAsByteArray(
	String^ password
)

Parameters

password
Type: System..::.String
The password to encrypt the workbook with. This parameter overrides the Encryption.Password.

Return Value

[Missing <returns> documentation for "M:OfficeOpenXml.ExcelPackage.GetAsByteArray(System.String)"]

Examples

Example how to return a document from a Webserver...
CopyC#
ExcelPackage package=new ExcelPackage();
/**** ... Create the document ****/
Byte[] bin = package.GetAsByteArray();
Response.ContentType = "Application/vnd.ms-Excel";
Response.AddHeader("content-disposition", "attachment;  filename=TheFile.xlsx");
Response.BinaryWrite(bin);

See Also