Jul 18

C# Image Dimension . Keep the dimension as it is when Exporting to Excel

System.Drawing.Image img = System.Drawing.Image.FromFile(@"c:\ggs\ggs Access\images\members\1.jpg");

int width = img.Width;
int height = img.Height;

---
Excel and Exporting

When you export to Excel using OpenXML standard
You usually mention where to start and where to end. I.e. cell to insert from and the width/height in number of cells.

Hence, you need to know how many pixels are in one cell for excel (if you want to keep the same height and width)

In general: 
64 pixels on the width
15 pixels on height
(may have an assumption here, Excel with Arial and 10 size font)
--

There are C# Classes and Methods to know/calculate how many pixels per cell.
It actually also depends on some configurations of the Excel file
---
When you use Calibri and 11 size font,
56 pixels on the width
and 17 pixels on height
may work

ideally, you should use code/C# classes to find out (pixels per cell) for the current document.

Still, if you want to use configurations and hard-coded numbers, you can provide the configurations in the web.config file under app.settings using key/value pair.
To retrieve:

WebConfigurationManager.AppSettings["WidthInPixelsForACell"];

--
Skip to toolbar