Generating excel file which store results returned from queries

I am beginner in scala. I am using scala version 2.11.12 and IntelliJ 2022.3.2. I have to use few hive queries and have to send result either as html format in an email or have to write into csv\excel.

Please suggest, also suggest if it is possible to test the code in IntelliJ

May I ask, why the old version of Scala? Is it required by Hive? In any case, you can just convert the query results into CSV, save as a file, and send that. Obviously, be careful to wrap and escape the fields CSV properly. Probably better to use CSV generator library, e.g. kantan.csv - Encoding case classes as rows