title: windows c# console app, try to use ms-interop.excel and clipboard, got some problem
body: <p>What I want to do is to develop a windows console app which load a excel file, get specified range and export to a jpg/png image file.
  I try to use <code>Microsoft.Office.Interop.Excel</code> and <code>Clipboard</code> to do this, but the copyPicture method which copy excel range to clipboard does not work.</p>
  
  <p>I am using windows10, visual studio 2017, and all of the references what I "using" have been added in to my project.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>using System;
  using System.Windows.Forms;
  using System.Drawing;
  using Excel = Microsoft.Office.Interop.Excel;
  
  namespace ConsoleApp1
  
  {
  class Program
  {
      static void Main(string[] args)
      {
  
          Excel.Application xlApp;
          Excel.Workbook xlWorkBook;
          Excel.Worksheet xlWorkSheet;
          Excel.Range range;
  
          string str;
          int rCnt = 0;
          int cCnt = 0;
  
          object misValue = System.Reflection.Missing.Value;
  
          xlApp = new Excel.Application();
          xlWorkBook = xlApp.Workbooks.Open(@"C:\Users\Public\Documents\testex.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
          xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
          Excel.Range rg = xlWorkSheet.Range["A1:B2"];
          rg.CopyPicture(Excel.XlPictureAppearance.xlScreen, Excel.XlCopyPictureFormat.xlBitmap);
  
          if (Clipboard.GetDataObject() != null) {
              IDataObject data = Clipboard.GetDataObject();
  
  
              if (data.GetDataPresent(DataFormats.Bitmap)) {
  
                  Image image = (Image)data.GetData(DataFormats.Bitmap, true);
                  image.Save(@"C:\Users\Public\Documents\testexcel.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
  
              }
          }
          Console.Read();
  
      }
  }
  }
  </code></pre>
  
  <p>In my code, everything can run.
  But <code>Clipboard.GetDataObject()</code> got a null.</p>