Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting data from a database into Excel spreadsheet

Status
Not open for further replies.

GigaG

Technical User
Aug 28, 2007
83
US
Does anyone know or could you please point me in the correct direction of how I would go about taking queried data from a mysql database and insert it nicely into an excl spreadsheet??

Any assistance is appreciated

MCP ACA-I CTP
 
Ohh and make sure your file is an xls file instead of csv, if you want Excel to treat the html correctly.

However I'd like to point out, that I'm not sure sending html to excel is a good thing. You end up with too much junk surrounding the real information.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
That does not seem to tranfer to excel correctly... It is just spitting out the html into the cells ...

$commaseparatedcontents.="<table><tr><td><font color=#FF0000>Red</font></td></tr></table>\r \n";
$commaseparatedcontents.="4,5,6,7";

MCP ACA-I CTP
 
ok... now that i saw the new thread you sent... that worked changing it to xls... which is great... but two questions one.... do you know why it would be saying that

"the file you are trying to open is in a different format from the one specified by the extension and may be corrupted??"

Also... what do you mean by extra stuff?? i understand the more you do with something period the larger and more crap there will be, but this how a user is manually making it and would like to automate the process for him if possible... if he is already doing this manually... is there really that much more crap doing it in HTML?

MCP ACA-I CTP
 
"the file you are trying to open is in a different format from the one specified by the extension and may be corrupted??"

I don't get that error, it opens without saying anything when I try it. Still it might be that your excel is more sensitive when it comes to contents that aren't exactly excel data.

All the html would be extra stuff.
Its good for presenting it in a webpage, but do you really need all that behind a spreadsheet? It might be just me, but i really see no need for all the html there in the actual excel file. I don't know if I'm making any sense.
Yes I understand the user saves the web page and then opens it in excel, but i don't see the use of all the html inside the spreadsheet. I would probably just copy the information into the spreadsheet rather than opening the html file.

Still it works and can be done, and f you need the niceties, like bolding and colors then yes it is useful.





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
This might be totaly off beam but you could script Excel in the browser to do all you want. You just need to do(love that expression !) is create an new activexobject in the browser specifying excel.exe as the object. You can then script all the VBA stuff you need to get colours, bold etc as you require.
To get it to work you will need to let the browser know it's ok to run activex that isn't signed , which for an intranet site is probabbly ok but maybe not for a web app. I used a finacial info site a couple of years ago caled which did this and it worked really well. I don't know if the consumer side of the site lets you do it but the professional one certainly did.
Alterntivly look at the SYLK file format (for download at which may give you more flexability than a .csv file. It was designded to enable portable spreadsheets origianly in multiplan. You would need the mime-type to make it work I would think. specfies application/excel so that should be ok.
Finally look at the content-disposition header to control how the browser handles the file.
 
Sorry forgot one more option. The office web components, which give you stripped down version of spreadsheet, chart and pivot table.
 
Thank you ingresman .... I will keep that in mind for future endevours, but I did get the export to work fine for now... The guy that I was designing this for wanted it specifically for excel sheets! :(

MCP ACA-I CTP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top