[]
        
(Showing Draft Content)

C1.Excel.C1XLBook.Save

Save Method

Save(string)

Saves the worksheet to a file.

Declaration
public void Save(string fileName)
Parameters
Type Name Description
string fileName

Name of the file to save.

Remarks
<p>The format used to save the file is automatically determined by the 

file name extension. "Xlsx" and "zip" files are saved as OpenXml; all others are saved as Biff8 files ("xls").

If the file can't be created, an exception is thrown. This typically indicates that the file is currently open by another application (such as Microsoft Excel).

Save(string, FileFormat)

Saves the worksheet to a file.

Declaration
public void Save(string fileName, FileFormat format)
Parameters
Type Name Description
string fileName

Name of the file to save.

FileFormat format

C1.Excel.C1XLBook.FileFormat value that specifies the type of file to save.

Save(Stream)

Saves the worksheet into a stream.

Declaration
public void Save(Stream stream)
Parameters
Type Name Description
Stream stream

Stream where the worksheet is saved.

Remarks

This method allows saving the workbook directly into streams without using temporary files. Typical uses include saving books to web page response streams or mail attachment streams.

Examples

The code below saves a C1XLBook into a MemoryStream, clears the book, then loads it back from the same stream.

// save book into new MemoryStream
MemoryStream ms = new MemoryStream();
_book.Save(ms);

// clear book
_book.Clear();

// load it back from the MemoryStream
ms.Position = 0;
_book.Load(ms);

Save(Stream, FileFormat)

Saves the worksheet into a stream.

Declaration
public void Save(Stream stream, FileFormat format)
Parameters
Type Name Description
Stream stream

Stream where the worksheet is saved.

FileFormat format

C1.Excel.C1XLBook.FileFormat value that specifies the format to save the worksheet in.