Ver Mensaje Individual
  #7  
Antiguo 04-06-2003
Avatar de marcoszorrilla
marcoszorrilla marcoszorrilla is offline
Capo
 
Registrado: may 2003
Ubicación: Cantabria - España
Posts: 11.221
Reputación: 10
marcoszorrilla Va por buen camino
Aquí tienes una parte de un ejemplo que tengo por aquí a mano:

Código:
procedure TfmMain.btExample2Click(Sender: TObject);
var
 WorkBook,Sheet,Cell: Variant;
 Col,iRow,Row : Integer;
 cl:integer;
 s:string;
begin
 WorkBook:=Excel.WorkBooks.Add;
 Sheet:=WorkBook.WorkSheets[1];
 Sheet.Name:='Colors';
 Row:=1;
 Sheet.Cells[Row,1]:='Red';
 Sheet.Cells[Row,2]:='Green';
 Sheet.Cells[Row,3]:='Blue';
 Sheet.Cells[Row,4]:='Color Sum';
 Sheet.Rows[Row].Font.Bold:=true;
 for iRow:=0 to 8 do begin
  Row:=iRow+2;
  if iRow<8 then cl:=iRow*32 else cl:=$FF;
  for Col:=1 to 3 do begin
   Cell:=Sheet.Cells[Row,Col];
   Cell.Value:=cl;
   if Col=1 then Cell.Font.Color:=cl//red
   else if Col=2 then Cell.Font.Color:=cl*256//green
   else Cell.Font.Color:=cl*256*256;//blue
  end;
  Cell:=Sheet.Cells[Row,4];
  s:=format('=A%d+256*B%d+256*256*C%d',[Row,Row,Row]);
  Cell.Formula:=s;
  Cell.Font.Color:=Cell.Value;
 end;
 Sheet.Cells.Columns.AutoFit;
end;
Un Saludo.
Responder Con Cita