foreach (DataRow r in dt.Rows) { iRow++; // add each row's cell data... iCol = 0; foreach (DataColumn c in dt.Columns) { iCol++; if (c.ColumnName == "Vendor Filename" && r[c.ColumnName] != null) { OLEObjects oleObjects = (Microsoft.Office.Interop.Excel.OLEObjects) xlWorkSheet.OLEObjects(Type.Missing); oleObjects.Add( Type.Missing, // ClassType HttpContext.Current.Server.MapPath("~/Entitelement_Files/" +"xyz.jpg"), // Filename true, // Link false, // DisplayAsIcon Type.Missing, // IconFileName Type.Missing, // IconIndex Type.Missing, // IconLabel Type.Missing, // Left Type.Missing, // Top Type.Missing, // Width Type.Missing // Height ); objSheet = (_Worksheet)xlSheets.get_Item(1); excel.Cells[iRow+1, iCol] = oleObjects; } else { excel.Cells[iRow + 1, iCol] = r[c.ColumnName]; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)