When I open the Excel file I generate using EPPlus (C#), I get "Do you want to replace the contents of the destination cells in [... .xlsx]PivotTable?"
As you can see in the screen shot below, there is nothing in the cell where I want the image to display. Even when I push the image beyond the outer edge of the PivotTable, I get this message (I had been placing beneath column C/3). When I select yes to the dialog quoted above, the image is finally placed on the sheet (if I select "no" it is not added), and the sheet looks like this:
This is the code I'm using to add the image:
int imageCol = _grandTotalsColumnPivotTable + 1; // -1; <= I really want it to be this
AddImage(pivotTableWorksheet, 1, imageCol);
. . .
private void AddImage(ExcelWorksheet oSheet, int rowIndex, int colIndex)
var excelImage = oSheet.Drawings.AddPicture("PRO*ACT Logo", _logo);
excelImage.From.Column = colIndex - 1;
excelImage.From.Row = rowIndex - 1;
excelImage.From.ColumnOff = Pixel2MTU(2);
excelImage.From.RowOff = Pixel2MTU(2);
public int Pixel2MTU(int pixels)
int mtus = pixels * 9525;
_xlApp.DisplayAlerts = false;
I use this code to add an image to Excel. It does not asks me to replace content. But I do not use PivotTables. Maybe that would make a difference.
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath("test.png")); var excelImage = ws.Drawings.AddPicture("My Logo", image); excelImage.SetPosition(1, 0, 10, 0);