NativeExcel for .Net Developer's Reference

IWorkbook.SaveAs Method (String)

Saves changes to the workbook in a different file.

[Visual Basic]
Function SaveAs( _ 
   ByVal Filename As String _ 
) As Boolean
[C#]
bool SaveAs(
   string Filename
);
[C++]
bool SaveAs(
   String* Filename
);
[JScript]
function SaveAs(
   String Filename
): 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, workbook saves the file in the current folder.

Return Value

Returns true if it succeeded, false otherwise.

Example

This example changes the name of the first sheet in book.xls.

[C#]
IWorkbook book = Factory.OpenWorkbook("book.xls");
if (book != null) {
    book.Worksheets[1].Name = "NewSheetName";
    book.SaveAs("book.xls");
} 
[Visual Basic]
Dim book As IWorkbook
book = Factory.OpenWorkbook("book.xls")
If Not book Is Nothing Then
    book.Worksheets(1).Name = "NewSheetName"
    book.SaveAs("book.xls")
End If 
[C++]
IWorkbook* book = Factory::OpenWorkbook(S"book.xls");
if (book != null) {
    book->Worksheets->Item[1]->Name = S"NewSheetName";
    book->SaveAs(S"book.xls");
} 

See Also

IWorkbook Interface | NativeExcel Namespace | IWorkbook.SaveAs Overload List | Factory Class