Ver Mensaje Individual
  #4  
Antiguo 28-03-2016
Avatar de jeremiselxi
jeremiselxi jeremiselxi is offline
Miembro
 
Registrado: ago 2008
Posts: 199
Reputación: 16
jeremiselxi Va por buen camino
Buenas tardes.

Realicé los ajustes de lugar para poder aplicarlo con el componente que utilizo el cual es: "TExcelApplication. ".

Adjunto el código que utilice para mostrar unos comentarios de una base de datos en el formato con que inicié mi pregunta.

Código Delphi [-]
procedure TForm_Fondos_fijos_reponibles.Button1Click(Sender: TObject);
var
 Start, Length: OleVariant;
  Libro : _WORKBOOK;
  Hoja  : _WORKSHEET;
 contar, i,colora:Integer;
Hojainicio:integer;
begin

ShowMessage('Espere un momento');
Libro := Excel.Workbooks.Add(Null, 0);
Hoja  := Libro.Sheets[1] as _WORKSHEET;


i:=0;


//Los comentarios
i:=i+3;
Hoja.Cells.Item[i,1]:='Comentarios Para el Informe.';

//Insertamos todos los registros al excel  y en dbgrid 1
  with DataModule_financiero.query_fondos_fijos_reponibles do
    begin
    first;
    contar:=0;
      while not EOF Do
        begin
        i:=i+1;
        contar:=contar+1;
        Hoja.Cells.Item[i,1]:='Caso No. ' +inttostr(contar)+ ', ' + DBGrid1.Fields[8].AsString;
        Hoja.Range['A'+ inttostr(i),'A'+ inttostr(i)].select;

        //Ponemos en negrita los 11 primeros caracteres
        Start := 1;
        Length := 11;
        Excel.ActiveCell.Characters[Start, Length].Font.FontStyle := 'Bold';

      Next;
   end;//while
end;//with

        Form_esperar.ProgressBar1.Position:= 0;
        Form_esperar.hide;

ShowMessage('Exportado con Exito!');

Excel.Visible[0] := true;

end;


y en resumen, el código utilizado para realizar poner los 11 primeros caracteres en negrita es:

Código Delphi [-]
        //Ponemos en negrita los 11 primeros caracteres
        Start := 1;
        Length := 11;
        Excel.ActiveCell.Characters[Start, Length].Font.FontStyle := 'Bold';

Ya que si utilizo el código

Código Delphi [-]
Excel.ActiveCell.Characters(1, 9).Font.FontStyle := 'Negrita';

Me da error en los paréntesis.

Muchas Gracias Roman porque sin ti no lo hubiera podido hacer.

Te debo una.
__________________
Cristo te ama, ven a d él, ya k te espera con los brazos abiertos. Dios te bendiga mucho
Responder Con Cita