NativeExcel for .Net Developer's Reference

IRange.SaveAs Method (String, XlFileFormat)

Saves the range 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, NativeExcel 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 range A3:F10 into CSV file.

[C#]
  book.Worksheets[1].Range["A3:F10"].SaveAs("range.csv", XlFileFormat.xlCSV);                
[Visual Basic]
  book.Worksheets(1).Range("A3:F10").SaveAs("range.csv", XlFileFormat.xlCSV)                
[C++]
  book->Worksheets->Item[1]->Range->Item[S"A3:F10"]->SaveAs(S"range.csv", XlFileFormat::xlCSV);                

See Also

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