NativeExcel for .Net Developer's Reference

IRange.SaveAsMethod(String, XlFileFormat)

Saves the range data to the specified file.

[Visual Basic]
FunctionSaveAs(_
ByValFilenameAsString,_
ByValFileFormatAsXlFileFormat_
)AsBoolean
[C#]
boolSaveAs(
stringFilename,
XlFileFormatFileFormat
);
[C++]
boolSaveAs(
String*Filename,
XlFileFormatFileFormat
);
[JScript]
functionSaveAs(
StringFilename,
XlFileFormatFileFormat
):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);                
[VisualBasic]
  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