title: How to Customize Exported Excel from Console Application?
body: <p><strong>How to Add custom Column headers ?</strong></p>
  
  <p>Here is the code I use in Console Application.
  It works correctly.</p>
  
  <pre><code>   public static void Main(string[] args)
      {
  
  
          string path = Environment.CurrentDirectory + @"\ExportFrmInventoryInvsupplierSupplier.xls";
          if (!File.Exists(path))
          {
              // Create a file to write to.
              using (StreamWriter sw = File.CreateText(path))
              {
                  //creating the file contents
              }
          }
          using (StreamWriter sw = File.CreateText(path))
          {
              SqlConnection cn = new SqlConnection("Data Source=DELL\\SQLSERVER1;Initial Catalog=Camo;Integrated Security=True;Trusted_Connection=True");
              //SqlConnection cn = new SqlConnection("Data Source=DELL\\SQLSERVER1;AttachDbFilename=|DataDirectory|\\Camo.mdf;Integrated Security=True;User Instance=True");
              SqlCommand cmd = new SqlCommand("SELECT distinct Inventory.LocalSKU, Inventory.ItemName, Inventory.Price, Inventory.Price2,InventorySuppliers.Cost,Suppliers.SupplierName,InventorySuppliers.SupplierSKU FROM Inventory Inner JOIN InventorySuppliers ON InventorySuppliers.LocalSKU =Inventory.LocalSKU Inner JOIN Suppliers ON  InventorySuppliers.SupplierID=Suppliers.SupplierID where InventorySuppliers.PrimarySupplier='True' order by Inventory.LocalSKU", cn);
              try
              {
                  cn.Open();
                  SqlDataReader dr = cmd.ExecuteReader();
  
                  while (dr.Read())
                  {
                      sw.WriteLine(dr["LocalSKU"].ToString() + "\t" + dr["ItemName"].ToString() + "\t" + dr["Price"].ToString() + "\t" + dr["Price2"].ToString() + "\t" + dr["Cost"].ToString() + "\t" + dr["SupplierName"].ToString() + "\t" + dr["SupplierSKU"].ToString());
                  }
  
                  Console.WriteLine("Exported Successfully...!!!");
              }
              catch (Exception excpt)
              {
                  Console.WriteLine(excpt.Message);
              }
  
          }
  
  
      }
  </code></pre>
  
  <p>Any Examples would be appreciated........................</p>