PDA

Ver la Versión Completa : determinar el tamaño de fuente en excel cuando esxporto una consulta


microbiano
12-10-2011, 00:57:35
hola resulta que no se como poner el tamano de fuente (letra) en un libro de excel cuando exporto una consulta, lo que me gustaria es saber:

* desde delphi como determinar el tamano de fuente
* desde delphi saber combinar consulta
* como determinar el separador de miles en cantidades


el codigo que utilizo para la exportacion es: Excel:=CreateOleObject('Excel.Application');
Excel.WorkBooks.Add (-4167);

Excel.WorkBooks[1].WorkSheets[1].Name := 'Reporte';
Libro := Excel.WorkBooks[1].WorkSheets['Reporte'];


// Son los titulos
i := 10;
Libro.Cells [1,1] := 'INSTITUTO';
Libro.Cells [2,1]:= 'DIRECCIÓN ';
Libro.Cells [3,1] := 'UNIDAD ';
Libro.Cells [4,1]:= 'COORDINACIÓN ';
Libro.Cells [5,1] := 'COORDINACIÓN ';
Libro.Cells [6,1] := 'DIVISION';
Libro.Cells [7,1]:=' ';
Libro.Cells [8,1] := 'RESUMEN DE IMPORTES';

Libro.Cells [i,1] := 'Licitación';
Libro.Cells [i,2] := 'claves requeridas';
Libro.Cells [i,3] := 'Piezas Requeridas';
Libro.Cells [i,4] := 'Importe requerido';
Libro.Cells [i,5] := 'Claves Asignadas';
Libro.Cells [i,6] := 'Piezas Asignadas';
Libro.Cells [i,7] := 'Importe Asignado';
Libro.Cells [i,8] := 'importe a PMR/MEDIANA';
Libro.Cells [i,9] := 'Ahorro Obtenido';


with Quick_reporte_lic do
begin
while not Quick_reporte_lic.Qry_1.Eof do
begin
i:=i+1;
libro.Cells[1,i ].Font.Name:='Arial'; //Tipo fuente
Libro.Cells [i,1] :=Qry_1.FieldByName ('licitacion').AsString;
Libro.Cells [i,2] :=Qry_1.FieldByName ('claves').AsInteger;
Libro.Cells [i,3] :=Qry_1.FieldByName ('piezas').AsInteger;
Libro.Cells [i,4] :=Qry_1.FieldByName ('importe').AsCurrency;
libro.cells.item[1,4].font.size:=4;
Libro.Cells [i,5] :=Qry_1.FieldByName ('claves_asig').AsInteger;
Libro.Cells [i,6] :=Qry_1.FieldByName ('cant_max_as').AsInteger;
Libro.Cells [i,7] :=Qry_1.FieldByName ('importe_asig').AsCurrency;
Libro.Cells [i,8] :=Qry_1.FieldByName ('importe_a_pmr').AsCurrency;
Libro.Cells [i,9] :=Qry_1.FieldByName ('ahorro').AsCurrency;
Next;
end;
end;
Excel.visible:=True;
end;

espero me puedan ayudar de antemano muchas gracias.

newtron
12-10-2011, 10:10:20
Hola, a ver si esto te sirve:


//Formato del número:
//Currency:
Hoja.Cells.Item[Y,X].NumberFormat := '#.##0,00';
//Entero:
Hoja.Cells.Item[Y,X].NumberFormat := '0';
//Tamaño de fuente:
Hoja.Cells.Item[Y,X].Font.size:=20;
//.... y de regalo:
//Fuente en negrita:
Hoja.Cells.Item[Y,X].Font.Bold:=true;
//Subrayado:
Hoja.Cells.Item[Y,X].Font.underline:=True;
//Negrita:
Hoja.Cells.Item[Y,X].Font.Bold:=true;
//Alineación:
Hoja.Cells.Item[Y,X].HorizontalAlignment := xlcenter; // xlright // xlleft


Saludos

microbiano
12-10-2011, 16:39:16
hola amigo gracias por responder ya habia intentado con ese codigo pero la verdad no funciona, sigo intentando

newtron
13-10-2011, 09:45:36
¿Qué versión de delphi usas?, porque a mi esas instrucciones me funcionan perfectamente.