title: Center-align entire worksheet
body: <p>My current code only aligns the first 5 lines of Excel worksheet:</p>
  
  <pre class="lang-psh prettyprint-override"><code>$xlCenter=-4108 
  $excel = New-Object -Com Excel.Application
  $excel.Visible = $True
  $excel.Rows.Item("1:5").HorizontalAlignment = $xlCenter
  </code></pre>
  
  <p>But there is no telling how many rows my program will read from a database. How to center align all the rows?</p>