Redirect the output to a .xls file

Hi,
I am using the sybase database server though unix platform and try to retrieve some data by the help of select statement, and my main issue is i want to redirect all the the data i.e. retrieve from the select statement to a .xls file with the same column name and the outputs. How can i do this and what is the script ?

Thanks.

If you are using perl then use SpreadSheet::WriteExcel module.
In shell script use

DATA=`isql -S SERVER -U username -P password <<EOF
SELECT * FROM TABLE
EOF`

echo $DATA > Data.csv

I'm not using PERL, i am using Shell Scripting. So can u say how to do that.

The Excel xls format is a binary file format. You'll have a very, very, very hard time writing it using only shell scripting. Better to use a scripting language like Perl for it, as you can use DBI, DBD::Sybase, and Spreadsheet::WriteExcel for a self-contained, platform-independent converter.

A different way would be to create a CSV as suggested, or to use ODBC to access the DB directly.

ok then how to redirect the output with column name to a .csv file ?

Read the first response to your message :mad: http://www.unix.com/shell-programming-scripting/128441-redirect-output-xls-file.html#post302389445