Re: Exportar datos a un ficher Excel

154 views
Skip to first unread message

Alex

unread,
Jul 23, 2012, 5:07:36 AM7/23/12
to ebd-...@googlegroups.com
Yo lo hice creando directamente el XML a partir de http://msdn.microsoft.com/en-us/library/aa140066%28office.10%29.aspx

En eBD es Archivo dinamico > fichero.xml , extensión text/xml

Un ejemplo:

<eBD:CODE>   
<eBD:ARGS NAME="q" DEFAULT=""/>

    <eBD:SET VAR="excel" VALUE='<?xml version="1.0"?>
                <?mso-application progid="Excel.Sheet"?>
                <Workbook
                   xmlns="urn:schemas-microsoft-com:office:spreadsheet"
                   xmlns:o="urn:schemas-microsoft-com:office:office"
                   xmlns:x="urn:schemas-microsoft-com:office:excel"
                   xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
                   xmlns:html="http://www.w3.org/TR/REC-html40">
                  <Styles>
                    <Style ss:ID="Default" ss:Name="Normal">
                      <Alignment ss:WrapText="1" ss:ShrinkToFit="1"/>
                    </Style>
                    <Style ss:ID="1">
                             <Font ss:Bold="1"/>
                    <Interior ss:Pattern="Gray25"/>
                    </Style>

                  </Styles>'/>

    <eBD:QUERY DATASOURCE="principal" NAME="getList">
        SELECT "_idRegistro" idreg FROM TABLE
    </eBD:QUERY>

    <eBD:IF EXPR="&getList > 0">
        <eBD:SET VAR="excel" VALUE='$excel <Worksheet ss:Name="AC">
                         <Table>
                            <Column ss:Width="300" ss:AutoFitWidth="1"/>
                        '/>
            <eBD:SET VAR="excel" VALUE='$excel <Row ss:StyleID="1">
                                <Cell ss:Index="1">
                                  <Data ss:Type="String">Administrador</Data>
                                </Cell></Row>
                        '/>
                       
                    <eBD:FOREACH QUERY="getList">
                            <eBD:FETCHROW QUERY="getList" NAME="regList"/>
                           
                            <eBD:SET VAR="excel" VALUE='$excel <Row>'/>                               
                            <eBD:SET VAR="excel" VALUE='$excel <Cell ss:Index="1">
                                                  <Data ss:Type="String">&regList.idreg</Data>
                                                </Cell>
                                            '/>
                            <eBD:SET VAR="excel" VALUE='$excel </Row>'/>
                        </eBD:FOREACH>
        <eBD:SET VAR="excel" VALUE='$excel </Table></Worksheet>'/>
    </eBD:IF>
    <eBD:SET VAR="excel" VALUE='$excel </Workbook>'/>
    <eBD:OUT VALUE="$excel"/>
</eBD:CODE>

Así me funciona para el excel 2007 sin ningun problema.

El dilluns 2 de juliol de 2012 12:47:56 UTC+2, Albert Comas va escriure:
Buenas, necesito exportar datos a un fichero Excel. Esto lo he hecho millones de veces en PHP y otros, pero ¿cómo se tendría que hacer en eBD?
Tengo ejemplos de exportación a PDF, sería algo parecido? (crear un XML y darle estilos con XSL).
O se tendría que crear un tmpfile, insertar código HTML y asignar de algún modo un mime-type de Excel y poner extensión .xsl?

Por favor a ver si alguien me podéis aclarar cómo se haría conceptualmente y si puedo conseguir algún código de ejemplo.

Gracias
Reply all
Reply to author
Forward
0 new messages