1. You must have the Excel ODBC driver in your ODBC32 Control
Panel Entry. Don't ask me how and when it gets installed: I
just used the one I found in a pretty stock installation :)
2. Configuration of the ODBC driver: add a DSN choosing the
Excel driver and give it a name (i.e. "excelsux" :)).
Point it to an existing worksheet.
3. In the worksheet select a range of cells then Insert->Name->Define
(YMMV, my Excel is in Italian) and give a name to the
selection (i.e. "myselection").
4. PHP code finally: :)
/* Didn't try to protect it via user/pwd */
if (($id = odbc_pconnect("excelsux"))) {
if (($r = odbc_exec($id, "SELECT * FROM myselection"))) {
odbc_result_all($r); // Or whatever you want
}
}
Problems as of now:
1. the field name is tricky somehow. The first field name is the first
value in the first column of your selection (and if there are spaces
you are into troubles). Also note that your first row shouldn't contain
any data since it's supposed to contain the field names. The problem
I encountered traversing the field names was that I always got just
the first one... any solution or hint is much appreciated :)
2. no INSERTs or UPDATEs, according to M$ documentation :/ But you
are free to pipe your results to any PHP supported DB :)
vo binh wrote :792
revert :
How I can output ASP to MS Exel ? Please
Piers Karsenbarg wrote :999
In answer to binh vo, to output into an excel table, all you need to do is have:
Response.ContentType = "application/vnd.ms-excel"
at the top of your script, then you just output normal HTML-style tables (i.e. new table: <table>, new row: <tr>, new cell: <td>) and thats all there is to it.