title: C# Print specific excel worksheets
body: <p>Currently I got this code that prints all worksheets in a workbook:</p>
  
  <pre><code>MyApp = new Excel.Application();
  MyApp.Visible = false;
  
  MyBook = MyApp.Workbooks.Open(generatedFile);
  
  foreach (Excel.Worksheet ws in MyBook.Worksheets)
  {
      Excel.PageSetup ps = (Excel.PageSetup)ws.PageSetup;
      ws.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape;
      ws.PageSetup.Order = Excel.XlOrder.xlDownThenOver;
      //ws.PageSetup.FitToPagesWide = 1;
      //ws.PageSetup.FitToPagesTall = 50;
      //ws.PageSetup.Zoom = false;
  }
  MyBook.Worksheets.PrintOutEx();
  
  MyBook.Close(SaveChanges: true);
  MyApp.Quit();
  System.Runtime.InteropServices.Marshal.ReleaseComObject(MyApp);
  </code></pre>
  
  <p>My question is how can I print only selected worksheets (ones where a specific cell is not empty) all on the same print job?</p>
  
  <p>If I'm not mistake calling <code>WorkSheet.PrintOut()</code> for n WorkSheets would create n print jobs, right?</p>