Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 09-03-2005
Avatar de alt126
alt126 alt126 is offline
Miembro
 
Registrado: dic 2004
Posts: 171
Poder: 20
alt126 Va por buen camino
Graficos en excel??

A ver si sabe alguien si es posible desde una aplicacion builder c++, ademas de generar un documento excel (que si se puede), generar una grafica en ese documento excel....

Gracias,

Antonio
Responder Con Cita
  #2  
Antiguo 09-03-2005
Avatar de OSKR
OSKR OSKR is offline
Miembro
 
Registrado: nov 2004
Ubicación: San Cristóbal/Táchira/Venezuela
Posts: 389
Poder: 20
OSKR Va por buen camino
/*Este es el fuente, al final esta el dfm*/

#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
}
void __fastcall TForm1::ComboBox1Select(TObject *Sender)
{


try

{ Variant Excel = Variant::CreateObject("Excel.Application");
Excel.OlePropertySet("Visible",true);
Variant MiColeccionLibros=Excel.OlePropertyGet("Workbooks");
MiColeccionLibros.OleProcedure("Add");
Variant MiLibro=MiColeccionLibros.OlePropertyGet("Item",1);
Variant MIColeccionHojas=MiLibro.OlePropertyGet("Worksheets") ;
MIColeccionHojas.OlePropertyGet("Item",1).OlePropertySet("Name","Hoja Uno");
Variant MiHoja=MIColeccionHojas.OlePropertyGet("Item",1);
MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1,1).OlePropertyGet("Font").OlePropertySet("Ita lic",true);

MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1,1).OlePropertyGet("Font").OlePropertySet("Bol d",true);

MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1,1).OlePropertyGet("Font").OlePropertySet("Siz e",13);

MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1,1).OlePropertyGet("Font").OlePropertySet("Col or",clNavy);

MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1,1).OlePropertySet("Value","Celdas:");

MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1,1).OlePropertyGet("Interior").OlePropertySet( "ColorIndex",ExcelAzulOscuro);

for (int indice=1;indice<=12;indice++)
{ MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1+indice,1).OlePropertyGet("Font").OlePropertyS et("Bold",true);
MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1+indice,1).OlePropertyGet("Font").OlePropertyS et("Size",10);

MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1+indice,1).OlePropertyGet("Font").OlePropertyS et("Color",clAqua);

MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1+indice,1).OlePropertyGet("Interior").OlePrope rtySet("ColorIndex",ExcelAzulOscuro);

MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1+indice,1).OlePropertySet("Value",indice*rand( ));

MiHoja.OlePropertyGet("Cells").OlePropertyGet("Item",1+indice,1).OlePropertySet("NumberFormat","#.## 0");

}



/*

RANGO DE CELDAS PARA LA GRAFICA

*/

Variant MiRango=MiHoja.OlePropertyGet("Range","A2:A13");



/*

GRAFICAS

*/

Variant MiColeccionGraficos=MiHoja.OlePropertyGet("ChartObjects");

MiColeccionGraficos.OleProcedure("Add",5,300,430,250);

Variant MiGrafico=MiColeccionGraficos.OlePropertyGet("Item",1);

AnsiString TituloPrincipal="TITULO";

AnsiString TituloEjeY="Eje Y";

AnsiString TituloEjeX="Eje X";

int Leyenda=1;

/*

1 con leyenda

0 sin leyenda

*/

int SeriesLabels=0;

/*

The number of rows or columns containing series labels

?????????

*/

int CategoryLabels=0;

/*

The number of rows or columns containing category labels

??????????

*/

int ContruccionGrafica=6;

/*

7-> barras con valores

6-> barras sin valores

5-> barras complementarias

*/

int TipoGrafico=ComboBox1->Text.SubString(0,(ComboBox1->Text.AnsiPos("-")-2)).ToInt();

/*

2 por barras horizontales

3 por barras verticales

5 tarta

11 por barras 3d

13 por tarta 3d

*/

MiGrafico.OlePropertyGet("Chart").OleProcedure("ChartWizard",

MiRango,

TipoGrafico,

ContruccionGrafica,

2,

CategoryLabels,

SeriesLabels,

Leyenda,

TituloPrincipal.c_str(),

TituloEjeX.c_str(),

TituloEjeY.c_str());

/*

CODIGO PARA CREAR UN GRAFICO

INDEPENDIENTE DE LA HOJA

COMO OBJETO AUTONOMO

Variant MiColeccionGraficos=MiLibro.OlePropertyGet("Charts");

MiColeccionGraficos.OlePropertyGet("Add");

Variant MiGrafico=MiColeccionGraficos.OlePropertyGet("Item",1);

Variant MiColeccionSeries= MiGrafico.OlePropertyGet("SeriesCollection");

MiColeccionSeries.OleProcedure("Add",MiRango);

MiRango=SegundaHoja.OlePropertyGet("Range","C5:C16");

MiColeccionSeries.OleProcedure("Add",MiRango);

MiRango=SegundaHoja.OlePropertyGet("Range","D516");

MiColeccionSeries.OleProcedure("Add",MiRango);

*/
Excel=Unassigned;
}

catch(...)

{

ShowMessage("FALLO EN APLICACION 'EXCEL'.");

}

}
/* EL DFM*/
object Form1: TForm1

Left = 317

Top = 169

Width = 388

Height = 127

Caption = 'GRAFICAS EXCEL'

Color = clBtnFace

Font.Charset = DEFAULT_CHARSET

Font.Color = clWindowText

Font.Height = -11

Font.Name = 'MS Sans Serif'

Font.Style = []

OldCreateOrder = False

PixelsPerInch = 96

TextHeight = 13

object Label1: TLabel

Left = 40

Top = 43

Width = 79

Height = 13

Caption = 'Tipo de Gr'#225'fica :'

end

object ComboBox1: TComboBox

Left = 128

Top = 40

Width = 209

Height = 21

AutoDropDown = True

ItemHeight = 13

TabOrder = 0

OnSelect = ComboBox1Select

Items.Strings = (

'2 - por barras horizontales'

'3 - por barras verticales'

'5 - tarta'

'11 - por barras 3d'

'13 - por tarta 3d')

end

end

Responder Con Cita
  #3  
Antiguo 10-03-2005
Avatar de alt126
alt126 alt126 is offline
Miembro
 
Registrado: dic 2004
Posts: 171
Poder: 20
alt126 Va por buen camino
Thumbs up Muchas Gracias!!

Me ha sido de gran ayuda!!!

Gracias,

Antonio
Responder Con Cita
  #4  
Antiguo 10-03-2005
Avatar de alt126
alt126 alt126 is offline
Miembro
 
Registrado: dic 2004
Posts: 171
Poder: 20
alt126 Va por buen camino
bueno...otra cosilla...

Para poner las labels de las categorias? En el codigo que pusiste solo pone, la grafica, pero pone titulos de categorias por defecto. HAy algunamanera de indicarle tu que titulos quieres que aparezcan?

Solo he visto la propiedad "CategoryLabels", y no se muy bien para que se utiliza, porque se supone que habria que poner un rango de celdas igual que para las series de datos.

Gracias,

Antonio
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 20:11:48.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi