NanoXLSX.Writer 3.0.0-rc.3
Loading...
Searching...
No Matches
NanoXLSX.WorkbookExtension Class Reference

Writer extension methods for the Workbook class. More...

Static Public Member Functions

static void Save (this Workbook workbook)
 Saves the workbook.
static async Task SaveAsync (this Workbook workbook)
 Saves the workbook asynchronous.
static void SaveAs (this Workbook workbook, string filename)
 Saves the workbook with the defined name.
static async Task SaveAsAsync (this Workbook workbook, string fileName)
 Saves the workbook with the defined name asynchronous.
static void SaveAsStream (this Workbook workbook, Stream stream, bool leaveOpen=false)
 Save the workbook to a writable stream.
static async Task SaveAsStreamAsync (this Workbook workbook, Stream stream, bool leaveOpen=false)
 Save the workbook to a writable stream asynchronous.

Detailed Description

Writer extension methods for the Workbook class.

Definition at line 12 of file WorkbookExtension.cs.

Member Function Documentation

◆ Save()

void NanoXLSX.WorkbookExtension.Save ( this Workbook workbook)
static

Saves the workbook.

Exceptions
NanoXLSX.Exceptions.IOExceptionThrows IOException in case of an error

This is an extension method, applied to the Workbook class. An example usage is:

Workbook wb = new Workbook("workboox.xlsx", "worksheet1");
// do some operations with wb, like adding cells
wb.Save(); // Will save the workbook as 'workbook.xlsx' in the execution path

Definition at line 26 of file WorkbookExtension.cs.

◆ SaveAs()

void NanoXLSX.WorkbookExtension.SaveAs ( this Workbook workbook,
string filename )
static

Saves the workbook with the defined name.

Parameters
filenamefilename of the saved workbook
workbookWorkbook reference
Exceptions
NanoXLSX.Exceptions.IOExceptionThrows IOException in case of an error

This is an extension method, applied to the Workbook class. An example usage is:

Workbook wb = new Workbook("worksheet1");
// do some operations with wb, like adding cells
wb.SaveAs("workboox.xlsx"); // Will save the workbook as 'workbook.xlsx' in the execution path

Definition at line 68 of file WorkbookExtension.cs.

◆ SaveAsAsync()

async Task NanoXLSX.WorkbookExtension.SaveAsAsync ( this Workbook workbook,
string fileName )
static

Saves the workbook with the defined name asynchronous.

Parameters
fileNamefilename of the saved workbook
workbookWorkbook reference
Returns
Task object (void)
Exceptions
NanoXLSX.Exceptions.IOExceptionMay throw an IOException in case of an error. The asynchronous operation may hide the exception.

This is an extension method, applied to the Workbook class. An example usage is:

private async Task CreateXlsx()
{
Workbook wb = new Workbook("worksheet1");
// do some operations with wb, like adding cells
await wb.SaveAsAsync("workboox.xlsx"); // Will save the workbook as 'workbook.xlsx' in the execution path
}

Definition at line 95 of file WorkbookExtension.cs.

◆ SaveAsStream()

void NanoXLSX.WorkbookExtension.SaveAsStream ( this Workbook workbook,
Stream stream,
bool leaveOpen = false )
static

Save the workbook to a writable stream.

Parameters
streamWritable stream
leaveOpenOptional parameter to keep the stream open after writing (used for MemoryStreams; default is false)
workbookWorkbook reference
Exceptions
NanoXLSX.Exceptions.IOExceptionThrows IOException in case of an error

This is an extension method, applied to the Workbook class. An example usage is:

Workbook wb = new Workbook("worksheet1");
// do some operations with wb, like adding cells
using(FileStream fs = new FileStream("workbook.xslx", FileMode.Create))
{
wb.SaveAsStream(fs); // Will save the workbook as 'workbook.xlsx' using a FileStream
}

The stream can also be kept open:

Workbook wb = new Workbook("worksheet1");
// do some operations with wb, like adding cells
using(MemoryStream ms = new MemoryStream())
{
wb.SaveAsStream(ms, true); // Will save the workbook into a MemoryStream
ms.Position = 0; // Rewind the stream
// use ms to do copy or save actions
}

Definition at line 133 of file WorkbookExtension.cs.

◆ SaveAsStreamAsync()

async Task NanoXLSX.WorkbookExtension.SaveAsStreamAsync ( this Workbook workbook,
Stream stream,
bool leaveOpen = false )
static

Save the workbook to a writable stream asynchronous.

Parameters
stream>Writable stream
leaveOpenOptional parameter to keep the stream open after writing (used for MemoryStreams; default is false)
workbookWorkbook reference
Returns
Task object (void)
Exceptions
NanoXLSX.Exceptions.IOExceptionThrows IOException in case of an error. The asynchronous operation may hide the exception.

This is an extension method, applied to the Workbook class. An example usage is:

private async Task CreateXlsx()
{
Workbook wb = new Workbook("worksheet1");
// do some operations with wb, like adding cells
using(FileStream fs = new FileStream("workbook.xslx", FileMode.Create))
{
await wb.SaveAsStreamAsync(fs); // Will save the workbook as 'workbook.xlsx' using a FileStream
}
}

The stream can also be kept open:

private async Task CreateXlsx()
{
Workbook wb = new Workbook("worksheet1");
// do some operations with wb, like adding cells
using(MemoryStream ms = new MemoryStream())
{
await wb.SaveAsStreamAsync(ms, true); // Will save the workbook into a MemoryStream
ms.Position = 0; // Rewind the stream
// use ms to do copy or save actions
}
}

Definition at line 179 of file WorkbookExtension.cs.

◆ SaveAsync()

async Task NanoXLSX.WorkbookExtension.SaveAsync ( this Workbook workbook)
static

Saves the workbook asynchronous.

Returns
Task object (void)
Exceptions
NanoXLSX.Exceptions.IOExceptionMay throw an IOException in case of an error. The asynchronous operation may hide the exception.

This is an extension method, applied to the Workbook class. An example usage is:

private async Task CreateXlsx()
{
Workbook wb = new Workbook("workboox.xlsx", "worksheet1");
// do some operations with wb, like adding cells
await wb.SaveAsync(); // Will save the workbook as 'workbook.xlsx' in the execution path
}

Definition at line 48 of file WorkbookExtension.cs.


The documentation for this class was generated from the following file: