I have a custom plugin to export a specific database table to a CSV file.

The problem is that i don't have any "Download" option... this just write the file on the screen .. I can't download it.

Here is the code

```
    function Code_CSV_export_page() {

    if( !current_user_can( 'manage_options' ) ){ return false; }
    if( !is_admin() ){ return false; }

    if (isset($_POST['export']))
    {
        global $wpdb, $ID_angebot;

        $ID_angebot = $_POST['ID_angebot_enter'];
        $filename =  date("Ymd") . '-' . 'Export-Angebot-' . $ID_angebot  . '.csv';

        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header('Content-Description: File Transfer');
        header("Content-Type: application/force-download"); 
        header("Content-type: text/csv");
        header("Content-Disposition: attachment; filename={$fileName}");
        header("Expires: 0");
        header("Pragma: public");

        $fh = @fopen( 'php://output', 'w' );

        $header_row = array(
            0 =>'ID ANGEBOT',
            1=>'ANGEBOT',
            2 =>'ENDDATUM',
            3 =>'FIRMENNAMEN',
            4 =>'CODE',
            5 =>'VERWENDET',
            6 =>'TITEL',
            7 =>'NACHNAME',
            8 =>'VORNAME',
            9 =>'HERUNTERLADEN DATUM'
        );
        $data_rows = array();

        $query = $wpdb->prepare("SELECT * FROM wpPGRmaplus_angebote WHERE `id_angebot`=$ID_angebot ");
        $results = $wpdb->get_results($query); 

        foreach ( $results as $result ) {
            $row = array();
            $row [0] = $result -> id_angebot;
            $row [1] = $result -> angebot_name;
            $row [2] = $result -> enddatum;
            $row [3] = $result -> firmenname;
            $row [4] = $result -> code;
            $row [5] = $result -> verwendet;
            $row [6] = $result -> Titel;
            $row [7] = $result -> Nachname;
            $row [8] = $result -> Vorname;
            $row [9] = $result -> herunterladen_datum;

            $data_rows[] = $row;
        }

        //fprintf( $fh, chr(0xEF) . chr(0xBB) . chr(0xBF) );

        // header avant ici
           fputcsv( $fh, $header_row );
        foreach ( $data_rows as $data_row ) {
           fputcsv( $fh, $data_row );
        }

        fclose( $fh );

        die();

     }

    ?>
    <div class="wrap">          
        <form method="post"  enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?>" >
            <table class="form-table">
                <tbody>
                    <tr><th> </br> </br> </th> </tr>
                    <tr><th> </br> </br> </th> <td style="padding-bottom:60px; font-size: 25px; font-weight:bold;">Exportcodes und ihre Benutzer </td> </tr>
                    <tr><th> </br>  </th> </tr>
                    <tr><th>ID des Angebots bezogen auf die Codeliste</th>
                    <?php $ID_angebot_enter = $custom_angebotenter["ID_angebot_enter"][0]; ?>        
                    <td style="padding-top:20px;" ><input class="regular-text" id="ID_angebot_enter" type="text" name="ID_angebot_enter" value="<?php echo $ID_angebot_enter;?>" /></br>
                    <i> <?php echo 'Die ID wird im Angebot angezeigt -> Teil "Wie benutzt man das Angebot in Wordpress?"'; ?></i> <br/>
                    <i> <?php echo 'ACHTUNG, Export der Datenbank, abhängig vom gewählten Angebot;' ?></i> <br/> <br/> <br/> </td>
            </tr>
                    <?php //récupération de l'id de l'offre
                    $ID_angebot = $_POST['ID_angebot_enter'];?>
                    <tr><th> Export in Excel File</th>
                    <td><input type="submit" name="export" value="EXPORT TO CSV"></td>
                    </tr>
                </tbody>
            </table>
        </form> 
    </div>
    <?php } ?>

```

I have searched a lot and tried so many thing.
I can't see anything more.... I need an outside eye...

Could you please help me ?

Many thanks in advance for your help

Timama