Excel - Hojas de excel desde Builder

 
Vista:
Imágen de perfil de Adrian
Val: 5
Ha aumentado su posición en 2 puestos en Excel (en relación al último mes)
Gráfica de Excel

Hojas de excel desde Builder

Publicado por Adrian (1 intervención) el 24/10/2020 10:33:17
Este framento de codigo me lo encontre por la web y lo cojonudo es que funciona, aunque yo no me entere de que esto de las variant.
Lanzo esta pregunta al foro haber si hay alguien que me pueda explicar estos fragmentos para poder yo rellenarlos a mi gusto, que de momento se que se puede

Gracias
Adrian


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Excel = CreateOleObject("Excel.Application");
Excel.OlePropertySet("Visible", true);
Libro=Excel.OlePropertyGet("Workbooks");
Libro.OleProcedure("Add");
Hoja=Libro.OlePropertyGet("Item",1);
Libro=Hoja.OlePropertyGet("Worksheets");
Libro.OlePropertyGet("Item",1).OlePropertySet("Name","The yellow book-keeping ");
Libro.OlePropertyGet("Item",2).OlePropertySet("Name","The red book-keeping ");
for (int j=1;j<3;j++)
{
Hoja=Libro.OlePropertyGet("Item",j);
for (int i=1;i<11;i++)
{
Hoja.OlePropertyGet("Cells").OlePropertyGet("Item",i,1).OlePropertySet("Value",i);
Hoja.OlePropertyGet("Cells").OlePropertyGet("Item",i,2).OlePropertySet("Value",i*5);
Celda=Hoja.OlePropertyGet("Cells").OlePropertyGet("Item",i,2);
Celda.OlePropertyGet("Font").OlePropertySet("Color",clBlue);
Celda.OlePropertyGet("Font").OlePropertySet("Bold",true);
Celda.OlePropertyGet("Interior").OlePropertySet("ColorIndex",9-3*j);
}
Hoja.OlePropertyGet("Cells").OlePropertyGet("Item",11,1).OlePropertySet("Value","=SUM(A1:A10)");
Hoja.OlePropertyGet("Cells").OlePropertyGet("Item",11,2).OlePropertySet("Value","=SUM(B1:B10)");
}
Excel.OlePropertySet("DisplayAlerts",false); //suppress the warning dialog on closing the server
Excel.OlePropertyGet("Workbooks").OlePropertyGet("Item",1).OleProcedure("SaveAs","test.xls");
//Excel.OleProcedure("Quit");
Excel=Unassigned;
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
-1
Responder