7

I am able to export table's data into CSV file but unable to export these data into excel file. Is here any query to export these data into excel file.

I am using this query to export data as a CSV file.

SELECT *
INTO OUTFILE 'C:/your-directory/your-filename.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM tableName

I used this for excel file after change file name like your-filename.xls but its adding extension .xls but giving data like csv.

2
  • 1
    CSV file opens up in excel isnt it Commented Dec 2, 2011 at 12:40
  • I know CSV file open up in excel but I have some special character like Chines etc which does not support by CSV either I open this into excel. So I want pure excel file for this character. Commented Dec 5, 2011 at 5:36

2 Answers 2

1

You cannot export your query result set directly in excel with SELECT INTO ... You can export in CSV format that can be easily opened by excel as you already done, but you cannot export directly in excel format.

Sign up to request clarification or add additional context in comments.

2 Comments

I know CSV file open up in excel but I have some special character like Chines etc which does not support by CSV either I open this into excel. So I want pure excel file for this character.
pure excel file can't be exported with a query, sorry... You have to process the data in the resultset in your java program and then export it in excel from there ...
0

you can use a converter csv to xls?

1 Comment

I can't use this scrip because I am writing code in Java so I want query only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.