NativeExcel suite v2.x

SaveDBGridAs method

Creates a new workbook. Exports DBGrid to worksheet. Saves the workbook to the specified file. Returns 1 if it succeeds.

Syntax

function SaveDBGridAs( Filename: WideString): integer;
FileNameWideString. A string that indicates the name of the file to be saved. You can include a full path; if you don't, component saves the file in the current folder.

Example

This example exports the DBGrid1 into Orders.xls workbook and Orders.html file.
begin
  DBGrid2Excel1.Workbook := nil; //Clears workbook
  DBGrid2Excel1.WorkSheetName := 'Orders sheet'; //Specifies name for new worksheet
  DBGrid2Excel1.DBGrid := DBGrid1; //Specifies the dbgrid for export
  DBGrid2Excel1.SaveDBGridAs('Orders.xls'); //Saves the dbgrid into Orders.xls 
  DBGrid2Excel1.SaveDBGridAs('Orders.html'); //Saves the dbgrid into Orders.html 
end;
Copyright © NikaSoft 2004-2010