View Full Version : populate drop down list

05-28-2004, 04:02 PM
Is it possible to populate a dropdown list from a file in excel. I know this can be done using mysql and i know how to do that but my boss wants to know if it can be done using excel since she is a total noob when it comes to this stuff. If it is possible does anyone know of a good tutorial or code script concerning this, i've searched google and havent come up with anything yet.

05-28-2004, 04:36 PM
it's possible but harder then doing it through mySQL.
The fat if it's possible is not realy a very good criteria. there are also matters of efficiency, universal applicability, performance, security ...

if possible, it's save the xls files as csv files. excell will treat them the same, but they are easier to handle inside PHP + google will turn up a lot more links to get you started.

05-28-2004, 05:18 PM
Conecting to Excel is just like connecting to MS Access. Assuming this is a Windows machine of course :rolleyes: The only thing is that it's easier to do if the worksheet has ranges set which a lot of excel people ignore.

$filename = "c:\spreadhseet\\test.xls";
$sheet1 = 1;
$sheet2 = "sheet2";
$excel_app = new COM("Excel.application") or Die ("Did not connect");
print "Application name: {$excel_app->Application->value}
\n" ;
print "Loaded version: {$excel_app->Application->version}
print $filename;
//$excel_app->Application->Visible = 1; #Make Excel visible.
$Workbook = $excel_app->Workbooks->Open($filename) or Die("Did not open $filename $Workbook");
$Worksheet = $Workbook->Worksheets($sheet1);
$excel_cell = $Worksheet->Range("C1");
for($i=1; $i<4;$i++)
for($j=1; $j<4;$j++)
$excel_cell = $Worksheet->Range($arr[$i].$j);
echo "
The value is $arr[$i].$j => " . $excel_cell->value;

$excel_result = $excel_cell->value;