title: How can I programmatically add rows to existing Excel table with Python
body: <p>Despite the various Python Excel-manipulation libraries and resources, I am unable to find a specific solution.</p>
  
  <p>Right now, I have a template Excel file where a table exists. I would like to write a Python program in order to populate this table. Is this possible with any of the existing Excel libraries? The template Excel file has a sheet with an empty table (1st screenshot). I want to programmatically populate the table with some data from elsewhere. e.g.</p>
  
  <p><a href="https://i.stack.imgur.com/PWjC4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PWjC4.png" alt="Initial Excel empty table"></a></p>
  
  <pre><code>data = [("TS0001", "1.0 Administration", "Root", "vdouk", "15/09/19", 8.0, "example 1"),
          ("TS0002", "1.0 Administration", "Root", "vdouk", "16/09/19", 3.0, "example 2"),
          ("TS0003", "4.0 Simulations", "Root", "vdouk", "16/09/19", 5.0, "example 3")]
  </code></pre>
  
  <p>Thus, I want finally to look like the 2nd screenshot. The total entries and subtotals are computed automatically from appropriate excel cell functions (already defined). Finally, note that this table is referenced from other parts of the workbook, meaning that it is a named data source (seen in the Excel name manager), so defining a new table will cause problems elsewhere. 
  Can someone direct me to the most appropriate solution?</p>
  
  <p><a href="https://i.stack.imgur.com/FuHBK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FuHBK.png" alt="Final table example"></a></p>
  
  <h2>Here's the working logic.</h2>
  
  <ol>
  <li>Open an existing excel file.</li>
  <li>Do not change any formatting.</li>
  <li>Do not delete any existing data.</li>
  <li>Update the excel file with new rows:  
  
  <ol>
  <li>Insert all new rows just below the header row.</li>
  <li>Make sure this puts new rows as part of the existing table.</li>
  </ol></li>
  <li>Save and close the excel file.</li>
  </ol>
  
  <h1>Update</h1>
  
  <p>Right now, I am using openpyxl. The workaround I do is to edit the template .xlsx and add empty rows to the table. Then I write as many rows as my data tuples are by using openpyxl. The table totals seem to work, however some other excel macros seem to be breaking.</p>