$xlsFile = $_FILES['fileupload']['tmp_name'];
$conn= new COM("ADODB.Connection") or die( "did not connect" );
$conn->Open("Provider=MSDASQL;Driver={Microsoft Excel Driver (*.xls)};DBQ=$xlsFile;ExtendedProperties=Excel 10.0;");
$SQL = "Select * FROM [Schedule$]";
$results = $conn->Execute($SQL);
$c=0;
$s = $results->fields->Count();
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 "<br />\r\n";
$results->movenext();
$c++;
}
okay, so not gonna even get into the nightmare that is a direct COM connection to the excel application, so please don't suggest it, already pulled my hair out with that, and i just don't feel that PHP supports it enough.
so on to this problem. this adodb connection opens up my excel file nicely (and because we don't have to open excel, saves on resources), reads out the contents of the entire file, and closes it again.
all works fine... EXCEPT!!!
it seems when it comes across a cell that isn't a string (say an integer, float or date) then it tries to convert it to a string, but looses the information contained within. the $results->fields[$i]->type shows that it's converted all cells to type 200, string format, but i'm loosing all my number and date values.
help? much!!!
working between the manual and microsoft knowledge base is a nightmare as i've gotta convert everything from VBScript. but i've got this far, and i don't wanna give up yet :p
i can't figure out whether there's a way i can define what data type i am pulling out, or whether there's a way i can pull out different data forms from the object ($results->fields[$i]->date doesn't work), or if i'm just missing something.
and no, the commercial classes available are also not an option as i'm on a budget, and i also think that $100 for something like this is ridiculous... but anyway 🙂
thanks in advance for any help...