converting xls file to txt file and xls to csv

I need to convert an excel file into a text file

and an excel file into a CSV file..

any code to do that is appreciated
thanks

forgot to mention that i am using a bash script to do this

OpenOffice seems to be able to batch-convert, and can be used from a commandline.

XML.com: Moving to OpenOffice: Batch Converting Legacy Documents

can i do this in a bash script.....

!!!!!!

PURELY bash, without relying on other applications?

This is not the sort of thing you can write a clever sed one-liner for. Your program must actually parse the data, interpret it, not just blindly rearrange it; excel and csv have nearly nothing in common except both being tabular. It'd be especially difficult in bash since bash doesn't really have any sort of complex data structures except one-dimensional arrays, and has a hard time processing binary data.

By the way. CSV files are text files.