NativeExcel2 for .Net Developer's Reference

IWorkbook.SaveAsMethod(String, XlFileFormat)

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

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);
} 
[VisualBasic]
Dim book As IWorkbook
book = Factory.OpenWorkbook("book.xls")
If Not book Is Nothing Then
    book.SaveAs("book.htm", XlFileFormat.xlHtml)
End If 
[C++]
IWorkbook* book = Factory::OpenWorkbook(S"book.xls");
if (book != null) {
    book->SaveAs(S"book.htm", XlFileFormat::xlHtml);
} 

See Also

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