Using VB.Net 2010 (Pro) to create an Excel 2010 spreadsheet.
I'm in the process of creating a report. At first, there were two images on the report. Our company logo and the customer's logo. These were "hard coded" as to the size. Now, I'm charged with re-writing the code to allow us to offer the report app to other customers, which means I need to allow the customer to choose their own image file to be put in the report.
The problem is, I only have a certain area for that logo image to go and the customer's image can (literally) be any size. What I need is to adjust the image size so that it does not overwrite (or be overwritten by) the text that will be going in the cells near it. Further complicating the situation is the fact that Excel deals with inches and points, and image files are in pixels (with no easy conversion).
Here is the code I used originally to place the image in the spreadsheet...
The original image size is 1.3" wide by .49" high (measured by me on a printout). Right or wrong, this has been working correctly so, ultimately, I need to keep the 1.3"w by .49" h ratio.
I also know that the original image is 123px wide and 47px high.
So here's my question...
Once I have an image file (whatever the user selected), how do I enlarge or shrink the image so that it will fit the hole where the image goes? I'm guessing that I can alter the height to match the original (maintaining aspect ratio), then compare the width. If the width is wider than the original, then alter the width to match the original. But I'm not sure exactly how to code it, nor do I know how to figure out the image height/width in inches to put in the AddPicture() procedure.