I am fairly new to C# and have successfully created a console app which queries my DB and returns the results in groups using the following code:
class Program
{
    static void Main(string[] args)
    {
        string connString = "Server=FakeServer;Database=example;Uid=NotYou;Password=nicetry";
        MySqlConnection conn = new MySqlConnection(connString); //connects to database
        MySqlCommand command = conn.CreateCommand();
        command.CommandText = "select field_pcis_project_number_value, field_pcis_pi_last_name_value, field_pcis_pi_first_name_value, field_pcis_pi_email_email from field_data_field_pcis_project_number pn inner join field_data_field_pcis_pi_last_name ln on pn.entity_id = ln.entity_id inner join field_data_field_pcis_pi_first_name fn on ln.entity_id = fn.entity_id inner join field_data_field_pcis_pi_email em on fn.entity_id=em.entity_id";
        try
        {
            conn.Open();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            throw;
        }
        MySqlDataReader reader = command.ExecuteReader();
        while(reader.Read())
        {
            Console.WriteLine(reader["field_pcis_project_number_value"].ToString());
            Console.WriteLine(reader["field_pcis_pi_last_name_value"].ToString());
            Console.WriteLine(reader["field_pcis_pi_first_name_value"].ToString());
            Console.WriteLine(reader["field_pcis_pi_email_email"].ToString());
            Console.WriteLine("\n");
        }
        Console.ReadLine();
    }
    public void CreateXLSFile(MySqlDataReader dt, string strFileName)
    {
    }
 }
I would now like to export the data into a new excel file and organize the data in such a manner that each Console.WriteLine(reader.. statement is a column and the values are imported into the corresponding columns.
How can I accomplish this?
Thanks in advance!
