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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to convert Mysql to Excel?

Status
Not open for further replies.

bnownlater

Programmer
Jan 16, 2002
8
US
I need to display data from MySQL to Excel format. I looked at several excel classes, but they are missing three things that I need.

1. To be able to output a cell larger than 255 characters.
2. Be able to keep line breaks in cells.
3. be able to format the cell widths

I am currently using a tab delimited set up with excel http headers, but I can not format the cell widths. Anyone have any ideas (Please don't refer me to Biffwriter)?
 
s:
It appears that 'several
PHP:
 excel classes' were employed but none suited.  While this question may be good on the MySQL forum, it appears that PHP is the intended method to convert the data.

b:
I am clueless about the Excel file format and how to format cells with PHP.  I have done similar tasks by outputting a formatted HTML table.  Excel can open HTML files and allow saves to the XLS format.

Could you format your table in Excel and do some ODBC magic to import the MySQL data?

- - picklefish - -

Why is everyone in this forum responding to me as picklefish?
 
What you need to find out first is if Excel lets you do this through a COM plug, if it does, start learning COM. I know it will let you do the formatting and the line breaks, if Excel allows cells over 255 chars I assume so does COM. In fact we have a VB app here which does all of that, so I'm pretty sure it's possible.

I don't think PHP is going to be your language of preference for this though, I may be wrong, but unless you want to go ground up writing the COM plugs I don't think anyone has written a connection like what you need.

I think you've described a need for some VB or maybe some Python... just about anything will play nicely with MySQL, I'd suggest finding yourself the more rare program which will play as nicely with Excel as you need.

-Rob
 
I echo that PHP may not be the most suitable solution here but it's capable of doing this...

Code:
<?php 
// starting word 
$word = new COM(&quot;word.application&quot;) or die(&quot;Unable to instanciate Word&quot;); 
print &quot;Loaded Word, version {$word->Version}\n&quot;; 

//bring it to front 
$word->Visible = 1; 

//open an empty document 
$word->Documents->Add(); 

//do some weird stuff 
$word->Selection->TypeText(&quot;This is a test...&quot;); 
$word->Documents[1]->SaveAs(&quot;Useless test.doc&quot;); 

//closing word 
$word->Quit(); 

//free the object 
$word->Release(); 
$word = null; 
?>

The COM object for Excel should reveal all the methods available to use on Excel. You should be able to do what you're aiming for - however, as far as displaying Paragraph Text inside Excel thru COM I'm not so sure - and Excel is not the best format for displaying chunks of text anyways so you'll probably have to compromise with the type of data u wish to display.

Rocco is the BOY!!

SHUT YOUR LIPS...
ROCCOsm.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top