(DM.dstRequest.FieldByName('Состояние').AsString = 'Повторный') then
DBGrid1.Canvas.Font.Color := clRed;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
procedure TfmRequests.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DM.dstRequest.Close;
end;
e
n
d
//Модуль для формирования отчетов и документов
interface
uses
Windows, SysUtils, Classes, ComObj, DB, Controls, Forms, ADODB, Math, DBGrids;
procedure Rep_Universal(ADBGrid: TDBGrid; NumCol: Integer; ACaption: string);
procedure Rep_Passport(DeviceID: Integer);
procedure Rep_DeviceMove;
procedure Rep_AllPlacesEquipment;
implementation
uses
uDM, DateUtils, Dialogs;
//Формирование отчета по выбранному набору данных (вывод заголовков видимых
//полей и их значений):
procedure Rep_Universal(ADBGrid: TDBGrid; NumCol: Integer; ACaption: string);
var
Excel: Variant;
i, j, Width: Integer;
begin
Excel := CreateOleObject('Excel.Application');
Screen.Cursor := crHourGlass;
try
try
Excel.Application.EnableEvents := False;
Excel.Workbooks.Add;
for i:=0 to NumCol-1 do
begin
//Вывод в шапку таблицы названий полей из DBGrid'а:
Excel.Cells[5,i+1] := ADBGrid.Columns[i].Title.Caption;
//Форматирование заголовка:
Width := Min(30, Trunc(ADBGrid.Columns[i].Width * 0.2));
Excel.Cells[5,i+1].ColumnWidth := Width;
Excel.Cells[5,i+1].Font.Bold := True;
end;
Excel.Cells[1,1] := Date;
Excel.Cells[3,1] := ACaption;
Excel.Cells[3,1].Font.Bold := True;
Excel.Cells[3,1].Font.Size := 12;
i := 5;