How to delete table in Excel but preserve comments using VSTO?
<p>I'm using the snippet below to convert an Excel range with data into a table. In some cases, I need to delete the table, but preserve comments in the cells. Is there a way I can achieve that? Also, is there a way to toggle the headers on/off? I tried the different options under <code>XlListObjectHasHeaders: Microsoft.Office.Interop.Excel.XlYesNoGuess.</code> but those didn't work. thanks for your help.</p>

<pre><code>finalRange.Worksheet.ListObjects.AddEx(
SourceType: Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange,
Source: finalRange,
XlListObjectHasHeaders: Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes);
</code></pre>

<p>I delete the table structure like this -</p>

<pre><code>finalRange.Worksheet.ListObjects.Item[1].Delete();
</code></pre>

<p>EDIT (solution for multiple tables):</p>

<pre><code>        foreach (var table in sheet.ListObjects)
        {
            Microsoft.Office.Interop.Excel.ListObject tempObj = (Microsoft.Office.Interop.Excel.ListObject)table;
            Microsoft.Office.Interop.Excel.Range tempRange = tempObj.Range;
            tempRange.ClearContents();        
        }
</code></pre>