NativeExcel2 for .Net Developer's Reference

IWorksheet.SaveAsMethod(String, XlFileFormat, ExportOptions)

Saves the worksheet data to the specified file.

[Visual Basic]
FunctionSaveAs(_
ByValFilenameAsString,_
ByValFileFormatAsXlFileFormat,_
ByValoptionsAsExportOptions_
)AsBoolean
[C#]
boolSaveAs(
stringFilename,
XlFileFormatFileFormat,
ExportOptionsoptions
);
[C++]
boolSaveAs(
String*Filename,
XlFileFormatFileFormat,
ExportOptions*options
);
[JScript]
functionSaveAs(
StringFilename,
XlFileFormatFileFormat,
ExportOptionsoptions
):bool;

Parameters

Filename
A string that indicates the name of the file to be saved. You can include a full path; if you don't, worksheet saves the file in the current folder.
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 worksheet one into CSV file.

[C#]
  book.Worksheets[1].SaveAs("book.csv", XlFileFormat.xlCSV);                
[VisualBasic]
  book.Worksheets(1).SaveAs("book.csv", XlFileFormat.xlCSV)                
[C++]
  book->Worksheets->Item[1]->SaveAs(S"book.csv", XlFileFormat::xlCSV);                

See Also

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