SpreadsheetGear 2017
SaveAs(String,FileFormat) Method
Example 






SpreadsheetGear Namespace > IWorkbook Interface > SaveAs Method : SaveAs(String,FileFormat) Method
Saves this workbook using the specified filename and FileFormat, and updates the FullName property.
Syntax
'Declaration
 
Overloads Sub SaveAs( _
   ByVal filename As System.String, _
   ByVal fileFormat As FileFormat _
) 
'Usage
 
Dim instance As IWorkbook
Dim filename As System.String
Dim fileFormat As FileFormat
 
instance.SaveAs(filename, fileFormat)
void SaveAs( 
   System.string filename,
   FileFormat fileFormat
)
procedure SaveAs( 
    filename: System.String;
    fileFormat: FileFormat
); 
function SaveAs( 
   filename : System.String,
   fileFormat : FileFormat
);
void SaveAs( 
   System.string* filename,
   FileFormat fileFormat
) 
void SaveAs( 
   System.String^ filename,
   FileFormat fileFormat
) 

Parameters

filename
fileFormat
Remarks
Note that the various workbook settings which make a workbook read-only in an end user workbookSet have no affect at this level.
Example
class Program
{
    static void Main()
    {
        // Create a new empty workbook in a new workbook set.
        SpreadsheetGear.IWorkbook workbook = SpreadsheetGear.Factory.GetWorkbook();
        // Set Sheet1!A1 to "Hello World!".
        workbook.Worksheets["Sheet1"].Cells["A1"].Value = "Hello World!";
        // Save to C:\MyData.xls as Excel file.
        workbook.SaveAs(@"C:\MyData.xls", SpreadsheetGear.FileFormat.XLS97);
        // Open C:\MyData.xls.
        workbook = SpreadsheetGear.Factory.GetWorkbook(@"C:\MyData.xls");
        // Output Sheet1!A1.
        System.Console.WriteLine(workbook.Worksheets["Sheet1"].Cells["A1"].Value.ToString());
    }
}
Module Program
    Sub Main()
        ' Create a new empty workbook in a new workbook set.
        Dim workbook As SpreadsheetGear.IWorkbook = SpreadsheetGear.Factory.GetWorkbook()
        ' Set Sheet1!A1 to "Hello World!".
        workbook.Worksheets("Sheet1").Cells("A1").Value = "Hello World!"
        ' Save to C:\MyData.xls as Excel file.
        workbook.SaveAs("C:\\MyData.xls", SpreadsheetGear.FileFormat.XLS97)
        ' Open C:\MyData.xls.
        workbook = SpreadsheetGear.Factory.GetWorkbook("C:\\MyData.xls")
        ' Output Sheet1!A1.
        System.Console.WriteLine(workbook.Worksheets("Sheet1").Cells("A1").Value.ToString())
    End Sub
End Module
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IWorkbook Interface
IWorkbook Members
Overload List
SaveAs(String,FileFormat,String) Method
Save Method
SaveToMemory(FileFormat) Method
SaveToStream(Stream,FileFormat) Method
Open(String) Method
OpenFromMemory(Byte[]) Method
OpenFromStream(Stream) Method
Protect Method
Unprotect Method