mirfut
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору neznayka3 Если DBGrid Ehlib - есть экспортная функция SaveDBGridEhToExportFile(TDBGridEhExportAsXLS,dbg,fName,true); Или вручную, в чем сложность ? for ii := 0 to dbg.Columns.Count-1 do begin s := dbg.Columns[ii].Title.Caption; if Pos('|', s)>0 then s := Copy(s, Pos('|',s)+1, Length(s)-Pos('|',s)); xls.Sheet[0].AsString[ii,Row] := s; end; xls.Sheet[0].ApplyFormat.Font(0,Row,dbg.Columns.Count-1,Row,Fnt); xls.Sheet[0].ApplyFormat.Alignment(0,Row,dbg.Columns.Count-1,Row,chaCenter,cvaCenter); Inc(row); dbg.DataSource.DataSet.DisableControls; dbg.DataSource.DataSet.First; while not dbg.DataSource.DataSet.Eof do begin for ii := 0 to dbg.Columns.Count-1 do case dbg.DataSource.DataSet.FieldByName(dbg.Columns[ii].FieldName).DataType of ftDate : xls.Sheet[0].AsDateTime[ii,Row] := dbg.DataSource.DataSet.FieldByName(dbg.Columns[ii].FieldName).AsDateTime; ftDateTime : xls.Sheet[0].AsDateTime[i,Row] := dbg.DataSource.DataSet.FieldByName(dbg.Columns[ii].FieldName).AsDateTime; ftString : xls.Sheet[0].AsString[i,Row] := dbg.DataSource.DataSet.FieldByName(dbg.Columns[ii].FieldName).AsString; ftFloat : xls.Sheet[0].AsFloat[i,Row] := dbg.DataSource.DataSet.FieldByName(dbg.Columns[ii].FieldName).AsFloat; else xls.Sheet[0].AsVariant[ii,Row] := dbg.DataSource.DataSet.FieldByName(dbg.Columns[ii].FieldName).Value; end; Inc(row); dbg.DataSource.DataSet.Next; end; |