0

John McNamara の Spreadsheet WriteExce は、Excel ファイルのダウンロードに問題なく動作します。

現在、この関数を使用して mysql からデータをエクスポートし、Excel を生成しています。アクションのダウンロードは正常に動作していますが、アクションのメール送信を作成したいと考えています。すべての設定が完了しましたが、アクション ダウンロードを変更して tmp に保存するだけです。たとえば、

しかし、Excel tmp を生成して電子メールで送信するにはどうすればよいでしょうか。

    <?php
        include("include/conexion.php"); // CONECT TO BBDD
        require_once('include/write_excel/Worksheet.php'); // CLASS EXCEL
        require_once('include/write_excel/Workbook.php'); // CLASS EXCEL
        include_once("include/Classes/class.phpmailer.php"); // CLASS EMAIL

        header("Content-type: application/vnd.ms-excel");
        header("Content-Disposition: inline; filename=$filename" );

        $filename = "Listado.xls";

        // Creating a workbook
        $workbook = new Workbook("-");
        $worksheet1 =& $workbook->add_worksheet('Listado');

        $formato_texto_negrita =& $workbook->add_format();
        $formato_texto_negrita->set_bold(0x2BC);
        $formato_texto_negrita->set_align('left');
        $formato_texto_negrita->set_size(8);

        $formato_texto =& $workbook->add_format();
        $formato_texto->set_align('left');
        $formato_texto->set_size(8);

        $formatot2 =& $workbook->add_format();
        $formatot2->set_align('right');
        $formatot2->set_size(8);

        $formato_numero =& $workbook->add_format();
        $formato_numero->set_align('right');
        $formato_numero->set_num_format('0.000,00;[Red]-0.000,00');
        $formato_numero->set_size(8);

        $i=3;
        $j=0;
        $k=0;
        $opcionListado = $_POST['opcionListado'];

        $worksheet1->set_column($k,$k++,10); // CLAVE
        $worksheet1->set_column($k,$k++,10); // Recepcion
        $worksheet1->set_column($k,$k++,15); // Ubicacion
        // NAME OF COLUMNS…..

        $res = mysql_query($query, $conexion);

        for($l=0;$row=mysql_fetch_array($res);$l++)
        {
        // DATE ROWS…….
        }

        file_put_contents($filename, $workbook->close());
?>

メールコードは他のphpに含まれています。

4

2 に答える 2

0

この記事は次のことに役立ちます。

http://www.html-form-guide.com/email-form/php-email-form-attachment.html

それができない場合は、このトピックがすでに複数回取り上げられているため、 Googleを使用することをお勧めします。

于 2013-02-25T13:28:57.320 に答える
0

通常どおりスプレッドシートを tmp ディレクトリに生成するだけです。次に、php メール ライブラリの迅速なメールを使用することをお勧めします。

この例を見てください

http://swiftmailer.org/docs/messages.html#attaching-dynamic-content

于 2013-02-25T14:43:18.990 に答える