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.
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.
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
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)
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>
Questo da inserire dove?
Vorrei inserire un pulsante che mi converta la pagina. Io come al solito non posso che continuare a ringraziarvi per l'interessecodice:<?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>
![]()
in alto metti
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 pulsantecodice:<?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"); } ?>
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>
Ho provato, ma non funziona.. e' come se disattivasse la conversione in xls. Il pulsante non funziona.![]()
Questo e' il codice completo:
Ma c'e' qualcosa che non funziona..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> <?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>