title: No data showing when programmatically creating Excel pivot table using C# and adding fields to row labels
body: <p>I'm trying to programmatically build an excel pivot table based on database table. I'm able to build a spreadsheet, and all of the database table columns are available as fields. But adding fields to the Row Labels box is not showing any data. </p>
  
  <p>If I look in the column filters it has correct values there, and if I add a field to the Values box, spreadsheet updates with correct data. So I know it connects to database and can get data out.</p>
  
  <p>I can build a pivot table by hand and adding fields to row labels box works fine, I'm trying to do the same in code. Any ideas on why I can't see any data?</p>
  
  <p>Here is the code I'm using:</p>
  
  <pre><code>        var excelApp = new Application();
          excelApp.CellDragAndDrop = false;
          excelApp.DisplayAlerts = true;
          Workbook workBook = excelApp.Workbooks.Add(Type.Missing);
  
          Worksheet worksheet = workBook.Worksheets.Add();
          worksheet.Name = "Test";
  
          PivotCache pivotCache = workBook.PivotCaches().Add(XlPivotTableSourceType.xlExternal, Type.Missing);
  
          pivotCache.Connection = myConnectionString;
          pivotCache.MaintainConnection = true;
          pivotCache.CommandText = "SomeTable";
          pivotCache.CommandType = XlCmdType.xlCmdTable;
  
          PivotTables pivotTables = worksheet.PivotTables();
          PivotTable pivotTable = pivotTables.Add(pivotCache, excelApp.ActiveCell, "TestingPivot", true, Type.Missing);
  
          excelApp.Visible = true;
  </code></pre>
  
  <p>Thank you for your help!</p>