Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/05/2009, 08:25
harvestmoon
 
Fecha de Ingreso: febrero-2009
Ubicación: cancun!
Mensajes: 898
Antigüedad: 16 años, 1 mes
Puntos: 15
ayuda exportar html a excel

hola foreros gracias por leer jaja yo aki molestando de nuevo con un problemilla
tengo un script donde esta una tabla q hago dinamicamente con php el chiste es q necesito q con un boton se exporte ese contenido a excel entonces me encontre con este codigo

Cita:
<script LANGUAGE=javascript>
function exportToXL(eSrc) {
var oExcel;
var oExcelSheet;
var oWkBooks;
var cols;
oExcel = new ActiveXObject('Excel.Application');
oWkBooks = oExcel.Workbooks.Add;
oExcelSheet = oWkBooks.Worksheets(1);
oExcelSheet.Activate();
if (eSrc.tagName != 'TABLE') {
alert('No ha sido posible exportar la tabla a excell');
return false;
}
cols = Math.ceil(eSrc.cells.length / eSrc.rows.length);
for (var i = 0; i < eSrc.cells.length; i ++)
{
var c, r;
r = Math.ceil((i+1) / cols);
c = (i+1)-((r-1)*cols);
if (eSrc.cells(i).tagName == 'TH') {
oExcel.ActiveSheet.Cells(r,c).Font.Bold = true;
oExcel.ActiveSheet.Cells(r,c).Interior.Color = 14474460;
}
if (eSrc.cells(i).childNodes.length > 0 && eSrc.cells(i).childNodes(0).tagName == "B")
oExcel.ActiveSheet.Cells(r,c).Font.Bold = true;
oExcel.ActiveSheet.Cells(r,c).Value = eSrc.cells(i).innerText;
}
oExcelSheet.Application.Visible = true;
}
</script>

esta funciona la llamo asi
Código HTML:
<input type="submit" name="exportxls" id="exportxls" value="Exportar Excel" onclick="exportToXL(form1.all('tablaexport'))" /> 
pero al probar el script me sale este error en la consola
firefox=Error: form1.all is not a function
Archivo de origen: http://localhost/blancareporte/index.php
Línea: 1



opera=message: Statement on line 3: Undefined variable: ActiveXObject
Line 3 of inline#1 script in http://localhost/blancareporte/index.php: In function exportToXL
var oExcel;
Line 1 of function script
exportToXL(form1.all('tablaexport'))



espero me puedan ayudar mil gracias!!!
aa y en explorer me lo intento abrir pero no paso nada solo me salio un mensajito de q el office no es original jaja :P pero no se abrio nada
gracias!!
__________________
WHERE IS MY BLUE SUNNY SKY??
pd: todos los karmas son bienvenidos :D