471,072 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,072 software developers and data experts.

Reading EXCEL (XLS) documents with other charactersets

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.

$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

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 = "";
$td = $cell->value;

echo "<td>" . $td . "</td>\n"; // #write the cell
echo "</tr>\n";
echo "</table>\n";

//closing excel

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

Nov 7 '06 #1
0 1681

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by hokiegal99 | last post: by
1 post views Thread by frankvfox | last post: by
6 posts views Thread by nitromuse | last post: by
reply views Thread by dt | last post: by
reply views Thread by aotemp | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.