title: Set table style. C# - closed xml
body: <p>I am looking for a way to apply a table style to the inserted data in an excel file.
  I use the library closed xml
  How can I do it?</p>
  
  <p>Sample table I want to get</p>
  
  <p><a href="https://i.stack.imgur.com/7Ww35.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Ww35.jpg" alt="enter image description here"></a></p>
  
  <pre><code>        using (XLWorkbook wb = new XLWorkbook(excel))
          {   IXLWorksheet ws = wb.Worksheets.Last();
              string Qry;
              using (SqlCommand cmd = new SqlCommand(Qry, sqlConn))
              {
                  sqlConn.Open();
                  using (SqlDataReader dr = cmd.ExecuteReader())
                  {
                      System.Data.DataTable schemaTable = dr.GetSchemaTable();
                      int i = 1;
                      foreach (DataRow rowt in schemaTable.Rows)
                      {
                      while (dr.Read())
                      {
                          row++;
                          for (int j = 0; j &lt; dr.FieldCount; j++)
                          {
                              if (!dr.IsDBNull(j))
                              {
                                  switch (dr.GetDataTypeName(j))
                                  {
                                      case "Varchar2":
                                          string s = dr.GetString(j);
                                          if (s.Substring(0, 1) == "=")
                                              s = " " + s;
                                          ws.Cell(row, j + 1).Value = s;
                                          break;
                                      case "nvarchar":
                                          ws.Cell(row, j + 1).Value = dr.GetString(j);
                                          break;
                                      default:
                                          break;
                                  }}}}}}}
  </code></pre>