excel - toad

Topics: Developer Forum, User Forum
Aug 1, 2011 at 10:21 PM

Hi, i have a php script that connect to active directory and retrive some fields and then generate an excel file(Excel5), then i connect by ODBC with TOAD to query the data from the excel file, but it not show me the first column and add a column, if i open and save the excel file, toad show me the data without problem, i think that the problem is the excel format that it generate

i use this code to retrive and generate the excel file, my script run in linux box

 

    if ($ldapbind) {
        //echo "LDAP bind successful...";
        $filter = "(cn=*)";
        $fields = array("uid","cn","whencreated","accountexpires","memberof");
        $sr = ldap_search($ldapconn, $dn, $filter, $fields);
        $info = ldap_get_entries($ldapconn, $sr);
                //print_r($info);
        //var_dump($info);
        $objPHPExcel->setActiveSheetIndex(0);
        $objPHPExcel->getActiveSheet()->setTitle('UsuariosAD');
        $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'NUM_DNI');
        $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'DES_PROVEEDOR');
        $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'FEC_INI_CON');
        $objPHPExcel->getActiveSheet()->SetCellValue('D1', 'FEC_FIN_CON');
        //echo "NUM_DNI\tDES_PROVEEDOR\tFEC_INI_CON\tFEC_FIN_CON\n";
        $objPHPExcel->setActiveSheetIndex(0);
        $k=2;
        for ($i=0; $i<$info["count"]; $i++)
        {
                for ($j=0; $j < count($info[$i]["memberof"]); $j++){
                        if ($info[$i]["memberof"][$j] == "cn=xx,dc=ssksk,dc=com")
                                //echo $info[$i]["uid"][0]."\t".$info[$i]["cn"][0]."\t".format_whencreated($info[$i]["whencreated"][0])."\t".convert_format_date($info[$i]["accountexpires"][0])."\n";
                        {               $objPHPExcel->getActiveSheet()->SetCellValue('A'.$k,$info[$i]["uid"][0]);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('B'.$k,$info[$i]["cn"][0]);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('C'.$k,format_whencreated($info[$i]["whencreated"][0]));
                                        $objPHPExcel->getActiveSheet()->SetCellValue('D'.$k,convert_format_date($info[$i]["accountexpires"][0]));
                                        $k++;
                                        $objPHPExcel->setActiveSheetIndex(0);
                        }
                }
        }
        // 2003
        $objPHPExcel->setActiveSheetIndex(0);
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
        $objWriter->save(str_replace('.php', '.xls','/opt/share/UsuariosAD.xls'));

Aug 2, 2011 at 9:36 PM

Hi, I think that i have the problem with the format, I generate the excel with Excel5 format, and when i open the file, this open in compatibility mode, is there a way to generate with 2003 format?, because i only see "Excel5" and "Excel 2007"