Pagina 2 di 3 primaprima 1 2 3 ultimoultimo
Visualizzazione dei risultati da 11 a 20 su 30

Hybrid View

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2014
    Messaggi
    17
    Clasku ciao e grazie per la risposta... Ho visto in molti siti dei moduli che convertono in xls delle tabelle, ma il file viene aperto senza errori.

  2. #2
    Utente di HTML.it
    Registrato dal
    Nov 2014
    Messaggi
    17
    Scusate un'ultimissima cosa, ho inserito il seguente codice:
    <?php
    $filename="file.xls";
    header ("Content-type:application/vnd.ms-excel");
    header ("Content-Disposition: attachment; filename=$filename");
    ?>

    Ma non riesco ad inserire la conversione in un pulsante. Mi converte la pagina in xls ogni volta che accedo alla pagina. Io vorrei che gli utenti visualizzino la tabella con la possibilita' cliccando sul pulsante di visualizzarla anche in xls. Grazie

  3. #3
    Utente di HTML.it L'avatar di clasku
    Registrato dal
    Aug 2006
    Messaggi
    3,197
    dipende sempre da come lo componi il file xls, magari i moduli usano classi che scrivono tutti i parametri che Excel considera validi e sicuri

    comunque, fossi in te farei una cosa tipo questa:
    - prepari la pagina web base e tutta la tabella la metti in una variabile;
    - a schermo fai l'echo della variabile che contiene la tabella;
    - la variabile che contiene la tabella la metti in sessione;
    - al click sul pulsante di "esportazione", richiami uno script che prende il dato relativo alla tabella dalla sessione e lo metti in un file xls.

    Il massimo sarebbe avere solo i dati che compongono la tabella nella sessione e non la struttura html della stessa, in modo che poi produci un file xls più pulito (per questo, guarda anche a classi come PHPExcel (https://phpexcel.codeplex.com)

  4. #4
    Quote Originariamente inviata da ninni87 Visualizza il messaggio
    Scusate un'ultimissima cosa, ho inserito il seguente codice:
    <?php
    $filename="file.xls";
    header ("Content-type:application/vnd.ms-excel");
    header ("Content-Disposition: attachment; filename=$filename");
    ?>

    Ma non riesco ad inserire la conversione in un pulsante. Mi converte la pagina in xls ogni volta che accedo alla pagina. Io vorrei che gli utenti visualizzino la tabella con la possibilita' cliccando sul pulsante di visualizzarla anche in xls. Grazie
    codice:
    <?php
    if(isset($_POST["action"]) and $_POST["action"] == "go")
    {
       $filename="file.xls";
       header ("Content-type:application/vnd.ms-excel");
       header ("Content-Disposition: attachment; filename=$filename");
    }
    ?>
    
    <form action="?">
    <input type="hidden" value="go" name="action">
    <input type="submit" value="Scarica in formato xls">
    </form>

  5. #5
    Utente di HTML.it
    Registrato dal
    Nov 2014
    Messaggi
    17
    Questo da inserire dove?
    codice:
    <?php
    
    <table summary="<?php echo htmlspecialchars($this->data->dmname)?>" cellspacing="0" >
    
    <?php
    if($this->theme->conf->details_name) :
        ?>
        <tr>
             <td><strong><?php echo _DML_TPL_NAME ?>:</strong></td><td><?php echo htmlspecialchars($this->data->dmname) ?></td>
         </tr>
        <?php
    endif;
    
    if($this->theme->conf->details_name) :
        ?>
         <tr>
             <td><strong><?php echo _DML_TPL_CIG ?>:</strong></td><td><?php echo $this->data->dmcig ?></td>
         </tr>
        <?php
    endif;
    
    if($this->theme->conf->details_name) :
        ?>
         <tr>
             <td><strong><?php echo _DML_TPL_SOG ?>:</strong></td><td><?php echo $this->data->dmsog ?></td>
         </tr>
        <?php
    endif; ?>
    </tbody>
    </table>
    Vorrei inserire un pulsante che mi converta la pagina. Io come al solito non posso che continuare a ringraziarvi per l'interesse

  6. #6
    in alto metti
    codice:
    <?php
    if(isset($_POST["action"]) and $_POST["action"] == "go")
    {
       $filename="file.xls";
       header ("Content-type:application/vnd.ms-excel");
       header ("Content-Disposition: attachment; filename=$filename");
    }
    ?>
    Poi metti il tuo codice e il modulo col pulsante submit che ti ho messo nel post precedente. La creazione del file xls avviene solo se si preme il pulsante

  7. #7
    Tipo cosi:
    codice:
    <?php
    if(isset($_POST["action"]) and $_POST["action"] == "go"){
       $filename="file.xls";
       header ("Content-type:application/vnd.ms-excel");
       header ("Content-Disposition: attachment; filename=$filename");
    }
    
    ?>
    <table summary="<?php echo htmlspecialchars($this->data->dmname)?>" cellspacing="0" >
    <?php
    if($this->theme->conf->details_name) :
    ?>
    <tr>
    <td>
      <strong>
       <?php echo _DML_TPL_NAME ?>:
      </strong>
     </td>
    
     <td>
      <?php echo htmlspecialchars($this->data->dmname) ?>
     </td>
    </tr>
    
    <?php
    endif;if($this->theme->conf->details_name) :
    ?>
    <tr>
     <td>
      <strong>
       <?php echo _DML_TPL_CIG ?>:</strong>
     </td>
     <td>
      <?php echo $this->data->dmcig ?>
     </td>
    </tr>
    
    <?php
    endif;
    
    if($this->theme->conf->details_name) :
    ?>
    <tr>
      <td>
       <strong><?php echo _DML_TPL_SOG ?>:</strong>
      </td>
      <td><?php echo $this->data->dmsog ?></td>
    </tr>
    
    <?php
    endif; 
    ?>
    </tbody>
    </table> 
    <form action="?">
    <input type="hidden" value="go" name="action">
    <input type="submit" value="Scarica in formato xls">
    </form>

  8. #8
    Utente di HTML.it
    Registrato dal
    Nov 2014
    Messaggi
    17
    Ho provato, ma non funziona.. e' come se disattivasse la conversione in xls. Il pulsante non funziona.

  9. #9
    Utente di HTML.it
    Registrato dal
    Nov 2014
    Messaggi
    17
    Questo e' il codice completo:
    codice:
    <?php
    if(isset($_POST["action"]) and $_POST["action"] == "go")
    {
       $filename="file.xls";
       header ("Content-type:application/vnd.ms-excel");
       header ("Content-Disposition: attachment; filename=$filename");
    }
    ?>
    
    <?php
    
    defined('_JEXEC') or die('Restricted access');
    
    
    $mainframe = JFactory::getApplication();
    $pathway  = & $mainframe->getPathWay();
    $pathway->addItem($this->data->dmname);
    
    JFactory::getDocument()->setTitle( _DML_TPL_TITLE_DETAILS . ' | ' . $this->data->dmname );
    ?>
    
    <div id="dm_details" class="<?php echo @$this->theme->conf->style ? 'dm_dark' : 'dm_light'; ?>">
    
    
    <h1 class="dm_title"><?php echo _DML_TPL_DETAILSFOR ?><em>&nbsp;<?php echo htmlspecialchars($this->data->dmname) ?></em></h1>
    
    <?php
    if ($this->data->dmthumbnail) :
        ?><img src="<?php echo $this->paths->thumb ?>" alt="<?php echo htmlspecialchars($this->data->dmname)?>" /><?php
    endif;
    ?>
    
    <table summary="<?php echo htmlspecialchars($this->data->dmname)?>" cellspacing="0" >
    
    <col id="prop" />
    <col id="val" />
    <thead>
        <tr>
            <td><?php echo _DML_PROPERTY?></td><td><?php echo _DML_VALUE?></td>
        </tr>
    </thead>
    <tbody>
    <?php
    if($this->theme->conf->details_name) :
        ?>
        <tr>
             <td><strong><?php echo _DML_TPL_NAME ?>:</strong></td><td><?php echo htmlspecialchars($this->data->dmname) ?></td>
         </tr>
        <?php
    endif;
    
    if($this->theme->conf->details_name) :
        ?>
         <tr>
             <td><strong><?php echo _DML_TPL_AFF ?>:</strong></td><td><?php echo $this->data->dmaff ?></td>
         </tr>
        <?php
    endif;
    
    if($this->theme->conf->details_name) :
        ?>
         <tr>
             <td><strong><?php echo _DML_TPL_IC ?>:</strong></td><td><?php echo $this->data->dmic ?></td>
         </tr>
        <?php
    endif;
    
    
    
    if($this->theme->conf->details_name) :
        ?>
         <tr>
             <td><strong><?php echo _DML_TPL_AGG ?>:</strong></td><td><?php echo $this->data->dmagg ?></td>
         </tr>
        <?php
    endif;
    
    if($this->theme->conf->details_downloads) :
        ?>
    
         <tr>
             <td><strong><?php echo _DML_TPL_LASTUP ?>:</strong></td>
             <td>
                 <?php  $this->plugin('dateformat', $this->data->dmlastupdateon , _DML_TPL_DATEFORMAT_LONG); ?>
             </td>
         </tr>
        <?php
    endif;
    ?>
    </tbody>
    </table>
    <div class="clr"></div>
    </div>
    
    <?php if(JRequest::getString('tmpl') != 'component') :?>
        <div class="dm_taskbar <?php echo @$this->theme->conf->style ? 'dm_dark' : 'dm_light'; ?>">
        <ul>
        <?php
            unset($this->buttons['details']);
            $this->doc = &$this;
            include $this->loadTemplate('documents'.DS.'tasks.tpl.php');
        ?>
        <li><a href="javascript: history.go(-1);"><?php echo _DML_TPL_BACK ?></a></li>
        </ul>
        </div>
    
    <?php endif; ?>
    <div class="clr"></div>
    </table>
    </body></html>
    
    <form action="?">
    <input type="hidden" value="go" name="action">
    <input type="submit" value="Scarica in formato xls">
    </form>
    Ma c'e' qualcosa che non funziona..

  10. #10
    Quote Originariamente inviata da ninni87 Visualizza il messaggio
    Questo e' il codice completo:
    codice:
    <?php
    if(isset($_POST["action"]) and $_POST["action"] == "go")
    {
       $filename="file.xls";
       header ("Content-type:application/vnd.ms-excel");
       header ("Content-Disposition: attachment; filename=$filename");
    }
    ?>
    
    <?php
    
    defined('_JEXEC') or die('Restricted access');
    
    
    $mainframe = JFactory::getApplication();
    $pathway  = & $mainframe->getPathWay();
    $pathway->addItem($this->data->dmname);
    
    JFactory::getDocument()->setTitle( _DML_TPL_TITLE_DETAILS . ' | ' . $this->data->dmname );
    ?>
    
    <div id="dm_details" class="<?php echo @$this->theme->conf->style ? 'dm_dark' : 'dm_light'; ?>">
    
    
    <h1 class="dm_title"><?php echo _DML_TPL_DETAILSFOR ?><em>&nbsp;<?php echo htmlspecialchars($this->data->dmname) ?></em></h1>
    
    <?php
    if ($this->data->dmthumbnail) :
        ?><img src="<?php echo $this->paths->thumb ?>" alt="<?php echo htmlspecialchars($this->data->dmname)?>" /><?php
    endif;
    ?>
    
    <table summary="<?php echo htmlspecialchars($this->data->dmname)?>" cellspacing="0" >
    
    <col id="prop" />
    <col id="val" />
    <thead>
        <tr>
            <td><?php echo _DML_PROPERTY?></td><td><?php echo _DML_VALUE?></td>
        </tr>
    </thead>
    <tbody>
    <?php
    if($this->theme->conf->details_name) :
        ?>
        <tr>
             <td><strong><?php echo _DML_TPL_NAME ?>:</strong></td><td><?php echo htmlspecialchars($this->data->dmname) ?></td>
         </tr>
        <?php
    endif;
    
    if($this->theme->conf->details_name) :
        ?>
         <tr>
             <td><strong><?php echo _DML_TPL_AFF ?>:</strong></td><td><?php echo $this->data->dmaff ?></td>
         </tr>
        <?php
    endif;
    
    if($this->theme->conf->details_name) :
        ?>
         <tr>
             <td><strong><?php echo _DML_TPL_IC ?>:</strong></td><td><?php echo $this->data->dmic ?></td>
         </tr>
        <?php
    endif;
    
    
    
    if($this->theme->conf->details_name) :
        ?>
         <tr>
             <td><strong><?php echo _DML_TPL_AGG ?>:</strong></td><td><?php echo $this->data->dmagg ?></td>
         </tr>
        <?php
    endif;
    
    if($this->theme->conf->details_downloads) :
        ?>
    
         <tr>
             <td><strong><?php echo _DML_TPL_LASTUP ?>:</strong></td>
             <td>
                 <?php  $this->plugin('dateformat', $this->data->dmlastupdateon , _DML_TPL_DATEFORMAT_LONG); ?>
             </td>
         </tr>
        <?php
    endif;
    ?>
    </tbody>
    </table>
    <div class="clr"></div>
    </div>
    
    <?php if(JRequest::getString('tmpl') != 'component') :?>
        <div class="dm_taskbar <?php echo @$this->theme->conf->style ? 'dm_dark' : 'dm_light'; ?>">
        <ul>
        <?php
            unset($this->buttons['details']);
            $this->doc = &$this;
            include $this->loadTemplate('documents'.DS.'tasks.tpl.php');
        ?>
        <li><a href="javascript: history.go(-1);"><?php echo _DML_TPL_BACK ?></a></li>
        </ul>
        </div>
    
    <?php endif; ?>
    <div class="clr"></div>
    </table>
    </body></html>
    
    <form action="?">
    <input type="hidden" value="go" name="action">
    <input type="submit" value="Scarica in formato xls">
    </form>
    Ma c'e' qualcosa che non funziona..
    Ma ti da un errore?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.