![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#7
|
||||
|
||||
|
Saludos
El problema de la consulta no actualizable es que me faltaba un parámetro en la conexión ADO, y parece ser un problema bastante global hehehehe. Asi quedo la cadena conexión: Código:
Provider=MSDASQL.1;Persist Security Info=False;Mode=ReadWrite;Extended Properties="DBQ=C:\mi_archivo.xls;Driver={Microsoft Excel Driver (*.xls)};DriverId=790;MaxBufferSize=2048;PageTimeout=5;ReadOnly=0;"
Código:
/*
http://www.clubdelphi.com/foros/showthread.php?t=10866
*/
Variant Excel,Libro,Hoja,Celda;
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","Pago periodo ");
//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=Unassigned;
Código:
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("SELECT * FROM [reporte$];");
ADOQuery1->Open();
Código:
ADOConnection1->Connected = true;
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("INSERT INTO [reporte$] (nombre, apellidos, edad) VALUES ('"+Edit1->Text+"', '"+Edit2->Text+"', '"+Edit3->Text+"')");
ADOQuery1->ExecSQL();
ADOConnection1->Connected = false;
ADOConnection1->Connected = true;
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("SELECT * FROM [reporte$];");
ADOQuery1->Open();
Espero que le sirva de ayuda a los próximos que lo intenten de todas formas pueden encontrar informacion de ayuda en el soporte que da microsoft y los ejemplos que pone para Visual Basic Cómo usar ADO con datos de Excel desde Visual Basic o desde VBA Cómo transferir datos desde un origen de datos ADO a Excel con ADO Cómo transferir datos de un objeto Recordset de ADO a Excel con automatización ExcelADO muestra cómo usar ADO para leer y escribir datos en libros de Excel
__________________
Nunca esta de más volver a ver la "Guia de Estilo" o "La Otra Guia de Estilo". Recuerda siempre usar los "Tags" para una mejor legibilidad de tu código. Cuando miras fijamente al abismo, este te devuelve la mirada oo______ooo_____ooo_ooooooo_____ooo____oooooo____ooooooo______oooo____ooo____oo_ oo______oooo___oooo_oo____oo__oo___oo__oo____oo__oo____oo___oo____oo__oooo___oo_ oo______oo_oo_oo_oo_oo____oo_oo_____oo_oo_____oo_oo____oo__oo______oo_oo_oo__oo_ oo______oo__ooo__oo_oooooo___ooooooooo_oo_____oo_ooooooo___oo______oo_oo__oo_oo_ oo______oo_______oo_oo_______oo_____oo_oo____oo__oo____oo___oo____oo__oo___oooo_ ooooooo_oo_______oo_oo_______oo_____oo_oooooo____oo_____oo____oooo____oo____ooo_ ________________________________________________________________________________ Última edición por lmpadron fecha: 26-09-2012 a las 16:20:31. |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Exportar Excel a PDF | BuenaOnda | Varios | 1 | 18-02-2011 10:51:17 |
| Exportar a Excel | jocey | Servers | 3 | 28-10-2008 22:33:28 |
| Exportar a Excel | jocey | Varios | 3 | 06-11-2007 16:15:23 |
| Exportar a Excel | Danielle | Impresión | 0 | 16-06-2006 18:04:55 |
| Exportar a Excel | pruz | Varios | 8 | 01-07-2004 15:47:37 |
|