[PHP-WIN] COM - ADODB connection...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



so i have something like this...

$xlsFile = $_FILES['fileupload']['tmp_name']; //the file we're reading is
the one we just uploaded
  $conn= new COM("ADODB.Connection") or die( "did not connect" );
  $conn->Open("Driver={Microsoft Excel Driver
(*.xls)};DBQ=$xlsFile;ExtendedProperties=Excel 8.0;");
  $SQL = "Select * FROM [Schedule$]";  // then we pull out all the info into
a record set from the sheet we want
  $results = $conn->Execute($SQL);
  $c=0;
  $s = $results->fields->Count();  // count it, and run through the record
set, putting it into an array...
  while(!$results->eof){
   for( $i=0; $i<$s; $i++ )
   {
    $sheets[$c][$i] = $results->fields[$i]->value."
[".$results->fields[$i]->type."]";
    print $sheets[$c][$i]."-";
   }
   print "\r\n";
   $results->movenext();
   $c++;
  }


the problem i'm having is that PHP seems to be loosing some information.
this scripts works perfectly in that it gets all the relevant info out of
the excel file. but when it comes to number only cells, or date cells, it
just looses the information. totally looses it. if i check
$results->fields[$i]->type it gives me that they are all type 200 (strings)
but it doesn't seem to be converting them to a string properly?

any help? is there any way i can specify how it converts them? or not to
convert them fully? the manual is very thin on any kind of good description
of the COM objects, and so is the internet. most people don't connect to
excel files this way, but connecting straight to excel just isn't viable,
and is riddled with bugs.



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux