Note that there are some explanatory texts on larger screens.

plurals
  1. POExcel - opening web page with umlaut (+ other characters) dislpay incorrectly
    text
    copied!<p>We have a German web site and data entered by the user includes umlaut's and other German characters. When we rum a report the data is displayed perfectly but if we then open the page in excel using mime-type it opens the file fine but the German characters are not being displayed properly.</p> <p>examples are as follows:</p> <p>ü displays as ü</p> <p>ö displays as ö</p> <p>We have had problems with other languages but these have been solved by putting this in the code after opening the database.</p> <pre><code>mysql_query( "set names 'utf8'" ) ; </code></pre> <p>How would we get Excel to display these characters.</p> <p>Any help appreciated</p> <p>Thanks Rich</p> <p>Here is the code causing the problem</p> <pre><code>&lt;?php ob_start(); ?&gt; &lt;!DOCTYPE html PUBLIC " - //W3C//DTD XHTMKL 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 -strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Forum Report&lt;/title&gt; &lt;link rel="shortcut icon" href="../templates/gk_music/favicon.ico" /&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="discussion" name="discussion" action="Discussion.php" method="post"&gt; &lt;div&gt; &lt;?php $message = $_REQUEST['signedin'] ; if ($message != "YES") { header( 'Location: index.php?option=com_user&amp;amp;view=login' ) ; } $ID = $_POST['ID']; $excelselected = $_POST['excel']; $print = $_POST['printit']; if ($print == "yes") { $excelselected = ""; } if ($excelselected == "excel") { &lt;?php header("Content-Type: application/x-msexcel"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Disposition: attachment; filename=discussion.xls"); ?&gt; header(System.Text.UTF8Encoding.Default); } $row_count = 0; $today = date("F j, Y"); $reporttitle = "Forum Report"; include("../CommCultureIncludes/DB.php"); $link = @mysql_connect($host, $username, $password); if (! $link){ die("couldnt connect to mysql ".mysql_error()) ; } @mysql_select_db( $database) or die ("Could Not Connect To Database : ".mysql_error() ); mysql_query( "set names 'utf8'" ) ; if ($excelselected != "excel") { include("../CommCultureIncludes/ReportHeaders.php"); if ($print == "yes") { $divoptions = "display:none"; } print "&lt;div id='divoptions' style='".$divoptions."' &gt;"; print "&lt;select class='dropdown' name='selectBox' id='selectBox' onchnge='OnChange(this.form.selectBox);'&gt;"; print "&lt;option value ='0' &gt;Select Discussion&lt;/option&gt;"; // set up dropdown $result = mysql_query("SELECT DISTINCT thread, subject FROM ".$prefix."kunena_messages WHERE parent = 0 ORDER By Subject"); while ($data = mysql_fetch_assoc($result)) { if ($ID == $data["thread"]) { print "&lt;option selected value =".$data['thread']."&gt;".$data['subject']."&lt;/option&gt;"; } else { print "&lt;option value =".$data['thread']."&gt;".$data['subject']."&lt;/option&gt;"; } } print "&lt;/select&gt;"; include("../CommCultureIncludes/ReportButtons.php"); print "&lt;br /&gt;&lt;br /&gt;"; print "&lt;/div&gt;"; } // display the results $SQL = "select a.name user, a.description, b.subject, b.time, c.message, d.id, d.username from ".$prefix."kunena_categories a, ".$prefix."kunena_messages b, ".$prefix."kunena_messages_text c, ".$prefix."users d where a.id = b.catid and b.thread = " .$ID. " and b.userid = d.id and b.id = c.mesid and b.hold = 0 ORDER BY b.time asc" ; $result = mysql_query( $SQL); $num_rows = mysql_num_rows ($result); print "&lt;table class='detailtable' width='80%' cellpadding='1' cellspacing='2' border=\"0\"&gt;\n"; while ($a_row = mysql_fetch_assoc( $result ) ) { if ( $User != $a_row["user"]) { print "&lt;tr class='reportheaders' nowrap valign='top'&gt;\n"; print "\t&lt;td colspan='5' &gt;Category : ".$a_row["user"]."&lt;/td&gt;\n"; print "&lt;/tr&gt;&lt;tr&gt;"; print "\t&lt;td colspan='3' class='reportheaders' &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Subject : ".$a_row["subject"]."&lt;/td&gt;\n"; Print "&lt;/tr&gt;\n"; $User = $a_row["user"]; Print "&lt;tr class='reportheaders' valign='top'&gt;\n"; print "\t&lt;td width='20%' &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Date&lt;/td&gt;\n"; print "\t&lt;td width='10%' &gt;User Name&lt;/td&gt;\n"; print "\t&lt;td colspan='3' &gt;Message&lt;/td&gt;\n"; if ($excelselected == "excel") { // print full details for excel filtering // select all field types $SQL = "select id, name FROM ".$prefix."community_fields where id not in (1,19,20,21) ORDER BY name" ; $fieldtypes = mysql_query($SQL); While ($b_row = mysql_fetch_assoc($fieldtypes) ) { print "\t&lt;td&gt;".$b_row["name"]."&lt;/td&gt;\n"; } } } Print "&lt;/tr&gt;\n"; if ($row_count % 2 != 0) { print "&lt;tr align='left' valign='top' class='reportdetailseven' nowrap&gt;"; } else { print "&lt;tr align='left' valign='top' class='reportdetailsodd' nowrap&gt;"; } $date = date('d-M-Y',$a_row["time"] ); $time = date('H:i:s',$a_row["time"] + 18000); print "\t&lt;td width='20%' &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;".$date." ".$time."&lt;/td&gt;\n"; print "\t&lt;td width='10%' &gt;".$a_row["username"]."&lt;/td&gt;\n"; print "\t&lt;td colspan='3' &gt;".$a_row["message"]."&lt;/td&gt;\n"; if ($excelselected == "excel") { // print full details for excel filtering // for each field type get field value select all field types $SQL = "select id, name FROM ".$prefix."community_fields where id not in (1,19,20,21) ORDER BY name" ; $fieldtypes = mysql_query($SQL); While ($b_row = mysql_fetch_assoc($fieldtypes) ) { $fieldvalues = mysql_query("SELECT * FROM ".$prefix."community_fields_values a, ".$prefix."users b WHERE a.field_id = '".$b_row ["id"]."' and a.user_id = b.id AND a.user_id = ".$a_row["id"]) ; $number = mysql_num_rows($fieldvalues); if ($number == '0') { print "\t&lt;td&gt;&amp;nbsp;&lt;/td&gt;\n"; } else { While ($c_row = mysql_fetch_assoc($fieldvalues) ) { print "\t&lt;td&gt;".$c_row["value"]."&lt;/td&gt;\n"; } } } } Print "&lt;/tr&gt;\n"; $row_count++; } print"&lt;/table&gt;\n"; include("../CommCultureIncludes/HiddenFields.php"); mysql_close( $link ); ?&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload