Linux下MySQL命令导出EXECL文件


这个说的不是用什么编程语言来实现这个功能,而是Linux下用Shell加上MySQL命令来实现。

Java代码

echo "use test;select * from test order by id desc;" | /usr/local/mysql/bin/mysql -uXXXX -pXXXX --default-character-set=utf8 > /tmp/test.xls

echo "use test;select * from test order by id desc;" | /usr/local/mysql/bin/mysql -uXXXX -pXXXX --default-character-set=utf8 > /tmp/test.xls

为了防止在windows下打开excel乱码,可以用iconv转一下码

Java代码

iconv -futf8 -tgb2312 -otest2.xls test.xls 

相关内容