NativeExcel for .Net Developer's Reference

IWorksheet.SaveAsMethod(Stream, XlFileFormat, ExportOptions)

Saves the worksheet data to the specified output stream.

[Visual Basic]
FunctionSaveAs(_
ByValoutputStreamAsStream,_
ByValFileFormatAsXlFileFormat,_
ByValoptionsAsExportOptions_
)AsBoolean
[C#]
boolSaveAs(
StreamoutputStream,
XlFileFormatFileFormat,
ExportOptionsoptions
);
[C++]
boolSaveAs(
Stream*outputStream,
XlFileFormatFileFormat,
ExportOptions*options
);
[JScript]
functionSaveAs(
StreamoutputStream,
XlFileFormatFileFormat,
ExportOptionsoptions
):bool;

Parameters

outputStream
The output stream.
FileFormat
XlFileFormat enumeration. A value that indicates format of the data to be saved. This method supports the following file formats: XlFileFormat.xlHtml, XlFileFormat.xlCSV, XlFileFormat.xlText, XlFileFormat.xlUnicodeCSV, XlFileFormat.xlUnicodeText.
options
ExportOptions. An object which contains export options.

Return Value

Returns true if it succeeded, false otherwise.

Example

This example saves all worksheet of book.xls into single CSV file.

[C#]
IWorkbook book = NativeExcel.Factory.OpenWorkbook("book.xls"); 
string FileName = "book.csv";

using (FileStream fs = new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.None)) 
{
    for (int i = 1; i <= book.Worksheets.Count; i++) 
    {
          book.Worksheets[i].SaveAs(fs, XlFileFormat.xlCSV);
    }    
}

See Also

IWorksheet Interface | NativeExcel Namespace | IWorksheet.SaveAs Overload List | ExportOptionsHtml Class | IWorksheet.SaveAs(System.String, NativeExcel.XlFileFormat) method | IRange.SaveAs(System.IO.Stream, NativeExcel.XlFileFormat) method | IWorkbook.SaveAs(System.IO.Stream, NativeExcel.XlFileFormat) method