K
K
Konstantin Dashkevich2017-02-15 23:19:15
excel
Konstantin Dashkevich, 2017-02-15 23:19:15

How to add an image to an Excel document by placing it under a specific cell?

Hello.
There is a report generated according to the template, the information in the Excel file is loaded using OpenXML.
You need to add several images under certain cells with text, which are added dynamically depending on the data. There are no problems with adding (I took from here polymathprogrammer.com/2010/11/10/how-to-insert-mu... The problem with calculating the position in pixels, i.e. I can’t calculate the coordinates. I
picked up the indent from above:

SheetFormatProperties sheetFormatProperties = worksheetPart.Worksheet.SheetFormatProperties;
double top = 0;
foreach (var row in worksheetPart.Worksheet.GetFirstChild<SheetData>().Elements<Row>())
{
  Console.WriteLine("Row: " + row.RowIndex.ToString());
  Console.WriteLine(row.Height != null ? row.Height.ToString() : sheetFormatProperties.DefaultRowHeight.ToString());
  top += row.Height != null ? row.Height : sheetFormatProperties.DefaultRowHeight;
}
top = top * 12 * 1200;

But with the indent on the left in pixels, the problem is, I did not find where to get the width of the column.
Can you please tell me where to look?
Perhaps there is a way to add an image to a specific cell?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question