0

I have nearly 50 to 60 queries that need to their data output to be exported as Excels. Writing an Java to iterate all the rows of output and pushing to excel will be a tough task to maintain in future if the queries change. Is there an easy way to iterate only through the queries and not the data to output all output to excels. If there is a simple command in MySQL or any way in Java to do this export.

1
  • If they're all related, then you can consider writing an SQL View comprising of all the data. And create one POJO corresponding to the VIEW. Commented Aug 14, 2015 at 21:36

1 Answer 1

2

One simple way would be to get MySQL output in CSV format, and then import it to MS Excel.

From this answer, here's how you get MySQL's output in CSV:

SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Sign up to request clarification or add additional context in comments.

Comments

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.