private void insertImage()
{
Excel.Application ThisApplication = new Excel.Application();
Excel.Workbook ThisWorkBook;
string _stFileName = "C:\\Users\\Rupam\\Desktop\\Test.xlsx";
string _stLOGO = "D:\\LOGO.bmp";
object missing = System.Reflection.Missing.Value;
try
{
ThisWorkBook = ThisApplication.Workbooks.Open(_stFileName, missing, missing, 5, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
Excel.Worksheet ThisSheet = (Excel.Worksheet)ThisWorkBook.Sheets[1];
Excel.Range oRange = (Excel.Range)ThisSheet.Cells[10, 1];
Image oImage = pictureBox1.Image;
System.Windows.Forms.Clipboard.SetDataObject(oImage, true);
ThisSheet.Paste(oRange, _stLOGO);
ThisWorkBook.Save();
}
catch (Exception oEx)
{ MessageBox.Show(oEx.Message); }
finally
{
ThisApplication.Quit();
ThisWorkBook = null;
ThisApplication = null;
}
}
See the msdn post here:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5bb5eb47-ea5e-4d97-a794-6266122552ea[
^]