NativeExcel for .Net Developer's Reference

IWorksheet.SaveAs Method (String, XlFileFormat)

Saves the worksheet data to the specified file.

[Visual Basic]
Function SaveAs( _ 
   ByVal Filename As String, _ 
   ByVal FileFormat As XlFileFormat _ 
) As Boolean
[C#]
bool SaveAs(
   string Filename,
   XlFileFormat FileFormat
);
[C++]
bool SaveAs(
   String* Filename,
   XlFileFormat FileFormat
);
[JScript]
function SaveAs(
   String Filename,
   XlFileFormat FileFormat
): 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.

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);                
[Visual Basic]
  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