title: Pandas dataframe to excel with color formatting using ExcelWriter and left alignment
body: <p>There is an answer to similar problem at another thread <a href="https://stackoverflow.com/questions/61649824/pandas-dataframe-dump-to-excel-with-color-formatting">here</a>.But I am looking to learn this using <code>Pandas ExcelWriter</code></p>
  
  <p>I have a large pandas dataframe <code>df</code> as:</p>
  
  <pre><code>Sou ATC   P25   P75 Avg
  A   11    9     15  10
  B   6.63  15    15  25
  C   6.63  5     10  8
  </code></pre>
  
  <p>I want to print this datamframe to excel file but I want to apply formatting to each row of the excel file such that following rules are applied to cells in <code>ATC</code> and <code>Avg</code> columns:</p>
  
  <ul>
  <li>colored in red if value is less than P25</li>
  <li>colored in green if value is greater than P75</li>
  <li>colored in yellow if value is between P25 and P75</li>
  </ul>
  
  <p>Sample display in excel is as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/N8DTb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N8DTb.png" alt="enter image description here"></a></p>
  
  <p>Please note the <strong>left aligned</strong> display of <code>column A</code>. I am also interested in learning how I can use <code>ExcelWriter</code> to left align the output to excel.</p>
  
  <p>A started code that I am using right now is:</p>
  
  <pre><code>writer = pd.ExcelWriter(r'C:\outfile.xlx', engine='xlsxwriter')
  df.to_excel(writer, sheet_name='mysheet', index=False)
  worksheet = writer.sheets['mysheet']
  </code></pre>
  
  <p>I am not sure how to approach this beyond the code above.</p>