Hello everyone!
I'm new and have a little problem with my excel script..
For a friend i have created a little script to read XLS files... in these XLS files there are a couple of COLUMS. Each collum contains a conversion of another colum.. like
COLUM A - Dutch language
COLUM B - Thai language
COLUM C - English language
so each 3 rows there are 3 words that means the same but in other languages.
Reading these values isn't the problem... i can read the data out of the XLS sheet... but only COLUM B displays ?? ? ? ?? ? because the carakterset is wrong in anyway!
This is the script
<style>
td {
font-family:"Angsana New";
panose-1:2 2 6 3 5 4 5 2 3 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:16777219 0 0 0 65537 0;
}
</style>
<?
function conv($string)
{
$str = "";
for ($x = 0; $x < strlen($string); $x++)
{
$str .= ord($x);
}
return $str;
}
$excel = new COM("excel.application") or die("Unable to instanciate excel");
//bring it to front
$excel->Visible = 1;//NOT
//dont want alerts ... run silent
$excel->DisplayAlerts = 1;
//open document
$excel->Workbooks->Open("d:/excel.xls");
for ($h = 1; $h <= 3; $h++)
{
$book = $excel->Workbooks(1);
$sheet = $book->Worksheets($h);
echo "<table>\n";
//Wtite row
for ($i = 1; $i <= 150; $i++)
{
echo "<tr>\n";
//write colom
for ($j = 1; $j <= 4; $j++)
{
// echo $sheet->cellsinfo();
$cell = $sheet->Cells($i, $j); // #Select the cell (Row Column number)
$cell->activate; // #Activate the cell
// echo ($cell->font->FontName);
if($cell->value == '0')
{
$td = "";
}
else
{
if ($j == 2)
{
// thai language so this needs to be converted in anyway!
$td = htmlspecialchars($cell->value);
}
else
{
$td = $cell->value;
}
}
echo "<td>" . $td . "</td>\n"; // #write the cell
}
echo "</tr>\n";
}
echo "</table>\n";
}
//closing excel
$excel->Quit();
?>
I've tried to search with google for help for my problem, even posted it on the usenet but didn't receive any answers that could help me solve this problem.
Also tried this..
<?php
$excel = new COM("excel.application", NULL, CP-874) or die("Unable to instanciate excel");
?>
and other CP charsets but didn't find the correct one..
Does anyone have an idea? i hope so... would like to fix this (hopefully little problem).
Ps sorry for my bad english!
Resources checked:
www.google.nl for excel.application / charset / thai / php and more..
www.phpbuilder.com/columns/alain20001003.php3
other forums and usenet..
Thanks for your time reading this topique!