title: Extract images from excel in a web application?
body: <p>When I upload a excel file to the server I want to extract the images in the uploaded file and store them in the root directory. I tried it with the windows application it works fine but does not seem to work for web applications. </p>
  
  <pre><code>Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
  Microsoft.Office.Interop.Excel.Workbook wb = excelApp.Workbooks.Open(file,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing,
                      Type.Missing);
  
  Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)wb.Sheets[1];   //Selects the first sheet
  Microsoft.Office.Interop.Excel.Range range = (Microsoft.Office.Interop.Excel.Range)ws.Cells[1, 1];      //Select cell A1
  object cellValue = range.Value2;
  
  #region Extract the image
  Microsoft.Office.Interop.Excel.Picture pic = (Microsoft.Office.Interop.Excel.Picture)ws.Pictures(1);
  
  if (pic != null)
  {
      //This code will detect what the region span of the image was
      int startCol = (int)pic.TopLeftCell.Column;
      int startRow = (int)pic.TopLeftCell.Row;
      int endCol = (int)pic.BottomRightCell.Column;
      int endRow = (int)pic.BottomRightCell.Row;
  
  
      pic.CopyPicture(Microsoft.Office.Interop.Excel.XlPictureAppearance.xlScreen, Microsoft.Office.Interop.Excel.XlCopyPictureFormat.xlBitmap);
      //From here How to save in the root directory ??
  }
  #endregion
  
  //Close the workbook
  wb.Close(false, Type.Missing, Type.Missing);
  
  //Exit Excel
  excelApp.Quit();
  </code></pre>
  
  <p>This code contains retrieves the image, but I can't figure it out how to save it in the root folder.</p>
  
  <p>I'm open to alternative ways of extracting images from a spread sheet as well.</p>