怎样将excel的某一行设置为蓝色?

解决方案 »

  1.   

    VAR qzw1: Variant;
    qzw1:=excelworksheet2.Range['A2','a1'];
    qzw1.Interior.ColorIndex:=3;
      

  2.   

    Rows[1].Font.Color := clBlue;
      

  3.   

    错了应该是: Sheet.Rows[1].Font.Color := clBlue;
      

  4.   

    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;
      

  5.   

    var
     WorkBook,Sheet,Cell: Variant;
     iRow,Row : Integer;
     NPaletteColors:integer;
    begin
     WorkBook:=Excel.WorkBooks.Add;
     Sheet:=WorkBook.WorkSheets[1];
     Sheet.Name:='Palette';
     Row:=1;
     Sheet.Cells[Row,1]:='Index';
     Sheet.Cells[Row,2]:='Color';
     Sheet.Cells[Row,3]:='RGB';
     Sheet.Rows[Row].Font.Bold:=true;
     NPaletteColors:=56;{WorkBook.Colors;}
     for iRow:=1 to NPaletteColors do begin
      Row:=iRow+2;
      Cell:=Sheet.Cells[Row,1];
      Cell.Value:=iRow;
      Cell:=Sheet.Cells[Row,2];
      Cell.Interior.ColorIndex:=iRow;
      Sheet.Cells[Row,3]:='0x'+inttohex(WorkBook.Colors[iRow],6);
     end;
     Sheet.Cells.Columns.AutoFit;
      

  6.   

    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;