[risolto] Creazione file excel con PHP

Garaux

Utente Attivo
24 Feb 2013
50
0
0
Salve, avrei una domanda in merito alla formattazione di un file excel creato in php.

Per farla breve...cliccando un tasto di una pagina web in cui viene visualizzata una tabella con diversi dati, creo un file excel grazie alla funzione sottostante:

PHP:
<?php

function setHeader($excel_file_name)//this function used to set the header variable
	{
		
		header("Content-type: application/octet-stream charset=utf-8");//A MIME attachment with the content type "application/octet-stream" is a binary file.
		//Typically, it will be an application or a document that must be opened in an application, such as a spreadsheet or word processor. 
		header("Content-Disposition: attachment; filename=$excel_file_name");//with this extension of file name you tell what kind of file it is.
		header("Pragma: no-cache");//Prevent Caching
		
		header("Expires: 0");//Expires and 0 mean that the browser will not cache the page on your hard drive
 	
	
	}
        
       if(isset($_POST['submit']))
       { 
        $body = $_POST['body'];
		$catName = $_POST['catName'];
        setHeader($catName.'.xls');
		//LINGUE ASIATICHE E CARATTERI SPECIALI
        echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
        echo $body;
        
       }

?>

Ho notato dei problemi di visualizzazione.
L'accento non viene mostrato come dovrebbe.
Nella tabella la parola Baha Boucles d'Oreilles viene visualizzata nel file excel cosi:
Baha Boucles d\'Oreilles con una slash prima dell'accento.

Sapreste dirmi come risolvere il problema?

Grazie!
 

Garaux

Utente Attivo
24 Feb 2013
50
0
0
Ciao, ho risolto facendo cosi:

PHP:
//Testo intero
$text = $body; 

//Apostrofo da sostituire
$oldWord = "\'"; 

//Apostrofo senza slash
$newWord = "'"; 

//Attivo la funzione str_replace
$body = str_replace($oldWord , $newWord , $text); 

//Mostro il contenuto nel file excel
echo $body;

Spero sia la strada giusta.
 
Discussioni simili
Autore Titolo Forum Risposte Data
T [Photoshop] Problema creazione pennello personalizzato [RISOLTO] Photoshop 3
M [RISOLTO] Creazione database MySQL 14
F [RISOLTO] Creazione slider con anteprima con jquery jQuery 8
D [RISOLTO]domande varie su creazione sito con php, mysql e phpmyadmin PHP 42
L (risolto) MySQL 0
B getElementById su piu id(Risolto) Javascript 7
L Esercitarsi con Js [RISOLTO] Javascript 4
C [RISOLTO]Inserimento variabile php in input html PHP 20
L risolto visualizzazione e ordinamento dati PHP 1
moustache [RISOLTO] SQL PHP IIS PHP 8
Sergio Unia Ricezione email con destinatari multipli [Risolto] PHP 2
L update tabelle in php mysql [risolto] PHP 6
M Semplice visualizzatore di immagini [risolto con plugin wp] PHP 7
L [RISOLTO] Stampa a video risultato count in html PHP 13
L [RISOLTO] Eliminare una discussione creata PHP 3
tomorc [HTML] Problema con scroll bar (risolto) HTML e CSS 0
A [PHP] Problema query insert [RISOLTO] PHP 14
B [PHP] recuperare IP dei server in load balancing [RISOLTO] PHP 3
K [RISOLTO] Problema Griglia Php+Mysql PHP 13
S [RISOLTO] aggiorna tabella da select option asp classic Classic ASP 7
elpirata [RISOLTO][Javascript] Datapicker e autocompletamento campo input Javascript 2
elpirata [RISOLTO][Mysql] Problema insert valori apostrofati MySQL 1
elpirata [RISOLTO][Mysql] Contare le occorrenze in un campo tipo varchar MySQL 2
G [MS Access] Gestione biglietti [RISOLTO] MS Access 2
G [MS Access] Casella combinata & Query [RISOLTO] MS Access 4
G [MS Access] Query mese corrente con conteggio [RISOLTO] MS Access 2
M [RISOLTO]Windows media player non mi funziona più su win 10 pro 64 bit Windows e Software 2
C [RISOLTO][PHP] Errore di sintassi PHP 8
IT9-Gpp [RISOLTO] Leggere variabile restituita da success Ajax 3
Kolop [RISOLTO][PHP] Problema Pagination PHP 2
C [RISOLTO][PHP] Funzione ONclick PHP 14
C [RISOLTO][PHP] Conteggio righe di una tabella PHP 4
N [PHP] Utilizzo variabili di sessione [Risolto] PHP 13
Tommy03 [RISOLTO][PHP] Webserver o devserver? PHP 2
Sergio Unia Recupero dati da una vecchia versione MySql [Risolto] MySQL 4
spider81man [PHP] Problemi cancellazione dato su DB [RISOLTO] PHP 1
A [RISOLTO]Inserimento Immagini da pc a MySql PHP 15
A [PHP] RISOLTO Invio Mail con Tabella PHP 2
felino Risolto - [Wordpress][WooCommerce] PayPal Checkout e campi di fatturazione WordPress 2
elpirata [PHP][RISOLTO] Sommare gli importi estratti da un ciclo while PHP 3
elpirata [PHP][RISOLTO] Effettuare la somma dei tempi di lavorazione PHP 3
elpirata [PHP] [RISOLTO]Sovrascrivere testo in una tabella PHP 2
A [RISOLTO]Recuperare dati inviati con json tramite php PHP 4
C [RISOLTO][PHP] Passaggio variabili senza refresh di pagina PHP 7
elpirata [PHP][RISOLTO] Errore di tipo Notice: Undefined index - Come risolvere quando si hanno tante var PHP 10
S Problema in PHP per invio file XML - RISOLTO- PHP 8
A [Javascript] [RISOLTO] Doppio "submit", in uno stesso "Form" , che puntino ad "action" diversi Javascript 1
marino51 [Risolto]videochat di messenger ha smesso di funzionare sul telefonino Smartphone e tablet 1
A [Javascript] [HTML] RISOLTO...Allungare un box all'apertura della pagina No Mouse over Javascript 9
ken_korn [Javascript][Risolto] browser.tab.Tabs.favIconUrl non funziona Javascript 5

Discussioni simili