Posted by Eric on 11/07/06 18:41
Hi all,
First i appoligise for my bad english.
For a friend i need to create a script that can read XLS documents. Well that's not the problem anymore... with the code (down here) i've already writen i can read tru the document. All rows and colums... but there one fault.. ROW A has normal characters (like A-Z) but row C contains thai carakters (using font : Angsana New in EXCEL or WORD). When i run the following script i see the words on ROW A displayed correctly but on row C wich contains THAI language words i only see
???? ? ???? ???? ???? (the other code i cannot post due weird carakters!)
I've been searching over the internet for days but havent found why! i've tried alot of scripts (both free or wich i need to pay for) but only a pricy script (like 80$) would show the carakters in ROW C correctly. If i convert the script to a HTML document i get the carakters with &# and a four digit number... that's what i like to extract from the excel sheet.
The script i wrote is.
Code:
<?php
$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 <= 5; $j++)
{
$cell = $sheet->Cells($i, $j); // #Select the cell (Row Column number)
$cell->activate; // #Activate the cell
if($cell->value == '0')
{
$td = "";
}
else
{
$td = $cell->value;
}
echo "<td>" . $td . "</td>\n"; // #write the cell
}
echo "</tr>\n";
}
echo "</table>\n";
}
//closing excel
$excel->Quit();
?>
the file excel.xls contains a couple of words on row A and the translation on row C.
I hope someone has a possible sollution for this problem!. If you like you may mail me personaly at eric [at] bruggema [dot] (netherlands) nl
[Back to original message]
|