NativeExcel2 for .Net Developer's Reference

IWorkbook.SaveAsMethod(String, XlFileFormat, ExportOptions)

Saves changes to the workbook in a different 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, workbook saves the file in the current folder.
FileFormat
XlFileFormat enumeration. A value that indicates format of the file to be saved.
options
ExportOptions. An object which contains export options.

Return Value

Returns true if it succeeded, false otherwise.

Example

This example changes format of book.xls to Excel 5/95.

[C#]
IWorkbook book = Factory.OpenWorkbook("book.xls");
if (book != null) {
    book.SaveAs("book.xls", XlFileFormat.xlExcel5);
} 
[VisualBasic]
Dim book As IWorkbook
book = Factory.OpenWorkbook("book.xls")
If Not book Is Nothing Then
    book.SaveAs("book.xls", XlFileFormat.xlExcel5)
End If 
[C++]
IWorkbook* book = Factory::OpenWorkbook(S"book.xls");
if (book != null) {
    book->SaveAs(S"book.xls", XlFileFormat::xlExcel5);
} 
This example opens book.xls and then saves it as HTML file.
[C#]
IWorkbook book = Factory.OpenWorkbook("book.xls");
if (book != null) {
    ExportOptionsHtml options = new ExportOptionsHtml();
    options.ShowGridLines = true;  
    book.SaveAs("book.htm", XlFileFormat.xlHtml, options);
} 

See Also

IWorkbook Interface | NativeExcel Namespace | IWorkbook.SaveAs Overload List | XlFileFormat Enumeration | ExportOptionsHtml Class