title: Encoding Issue while reading Excel file through PHP COM
body: <p>I am reading an excel spreadsheet with PHP COM utility, everything is working fine except there are some cells in Excel file having different language data. When I read this data through PHP Com it displays like <strong>???????</strong></p>
  
  <pre><code>$ExlApp = new COM ( "Excel.Application" );
  $workbook = $ExlApp-&gt;Workbooks-&gt;Open ( 'f:\dev\htdocs\excel\testfile.xlsx' );
  $worksheet = $workbook-&gt;worksheets ( 1 );
  
  $done = false;
  $row_index = 1;
  while ( $done == false ) {
  
      $english = $worksheet-&gt;cells ( $row_index, 1 )-&gt;value;
      $dari = $worksheet-&gt;cells ( $row_index, 2 )-&gt;value;
  
      if ($english != '') {
          $row_index ++;
          echo "&lt;div style='float:left;width:420px'&gt;".$english."&lt;/div&gt;&lt;div&gt;".$dari."&lt;/div&gt;";
      } else {
          $done = true;
      }
  }
  
  $workbook-&gt;close ();
  </code></pre>
  
  <p>I have checked page encoding and its set to UTF-8. When I open original excel file it shows correct text but when I read it from PHP COM the encoding is lost. Does anyone have solution to this problem. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>How I can ensure that the value given by excel <strong>$worksheet->cells ( $row_index,2)->value</strong> is in correct encoding OR is there any property in Excel which I can set through PHP COM so it return data in UTF-8?</p>
  
  <p>I have checked the encoding of value returned by Excel cell through mb_detect_encoding function in PHP and it gives ASCII where as it must give UTF-16 or UTF-8. It appears that excel does  not give value in correct encoding.</p>
  
  <p>Here is the Excel file I am reading with this script:
  <a href="http://asimishaq.com/myfiles/testfile.xlsx" rel="nofollow">http://asimishaq.com/myfiles/testfile.xlsx</a></p>
  
  <p>Note that the solution is required using PHP COM-INTEROP only.</p>