Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    populate drop down list

    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.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Conecting to Excel is just like connecting to MS Access. Assuming this is a Windows machine of course The only thing is that it's easier to do if the worksheet has ranges set which a lot of excel people ignore.

    Code:
    <? 
    $filename = "c:\spreadhseet\\test.xls"; 
    $sheet1 = 1; 
    $arr=array(1=>'a','b','c','d'); 
    $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}
    \n"; 
    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); 
    echo "AMIT YADAV
    "; 
    $Worksheet->activate; 
    $excel_cell = $Worksheet->Range("C1"); 
    $excel_cell->activate; 
    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; 
    
    $Workbook->Close; 
    unset($Worksheet); 
    unset($Workbook); 
    $excel_app->Workbooks->Close(); 
    $excel_app->Quit(); 
    unset($excel_app); 
    ?>
    Carl McDade
    _____________
    Hiveminds Magazine
    for web publisher and community builders
    eRuby Tutorials


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •