{"id":23073,"date":"2021-03-24T19:48:15","date_gmt":"2021-03-24T23:48:15","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/c-image-dimension-keep-the-dimension-as-it-is-when-exporting-to-excel-root-by-sayed-ahmed\/"},"modified":"2025-05-11T20:19:39","modified_gmt":"2025-05-11T20:19:39","slug":"c-image-dimension-keep-the-dimension-as-it-is-when-exporting-to-excel-root-by-sayed-ahmed","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=23073","title":{"rendered":"C# Image Dimension . Keep the dimension as it is when Exporting to Excel #Root #By Sayed Ahmed"},"content":{"rendered":"<pre class=\"lang-cs prettyprint prettyprinted\"><code><span class=\"typ\">System<\/span><span class=\"pun\">.<\/span><span class=\"typ\">Drawing<\/span><span class=\"pun\">.<\/span><span class=\"typ\">Image<\/span><span class=\"pln\"> img <\/span><span class=\"pun\">=<\/span> <span class=\"typ\">System<\/span><span class=\"pun\">.<\/span><span class=\"typ\">Drawing<\/span><span class=\"pun\">.<\/span><span class=\"typ\">Image<\/span><span class=\"pun\">.<\/span><span class=\"typ\">FromFile<\/span><span class=\"pun\">(<\/span><span class=\"str\">@\"c:ggsggs Accessimagesmembers1.jpg\"<\/span><span class=\"pun\">);\r\n<\/span>\r\n<span class=\"typ\">int width = <\/span><span class=\"pln\">img<\/span><span class=\"pun\">.<\/span><span class=\"typ\">Width;\r\n<\/span>int height = <span class=\"pln\">img<\/span><span class=\"pun\">.<\/span><span class=\"typ\">Height;<\/span><span class=\"pun\">\r\n\r\n<\/span><\/code>---\r\n<strong>Excel and Exporting<\/strong>\r\n\r\nWhen you export to Excel using OpenXML standard\r\nYou usually mention where to start and where to end. I.e. cell to insert from and the width\/height in number of cells.\r\n\r\nHence, you need to know how many pixels are in one cell for excel (if you want to keep the same height and width)\r\n\r\nIn general: \r\n64 pixels on the width\r\n15 pixels on height\r\n(may have an assumption here, Excel with Arial and 10 size font)\r\n--\r\n\r\nThere are C# Classes and Methods to know\/calculate how many pixels per cell.\r\nIt actually also depends on some configurations of the Excel file\r\n---\r\nWhen you use Calibri and 11 size font,\r\n56 pixels on the width\r\nand 17 pixels on height\r\nmay work\r\n\r\nideally, you should use code\/C# classes to find out (pixels per cell) for the current document.\r\n\r\nStill, 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.\r\nTo retrieve:\r\n\r\nWebConfigurationManager.AppSettings[\"WidthInPixelsForACell\"];\r\n\r\n--<\/pre>\n<p> From: http:\/\/sitestree.com\/?p=2099<br \/> Categories:Root, By Sayed Ahmed<br \/>Tags:<br \/> Post Data:2015-07-18 22:49:17<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>System.Drawing.Image img = System.Drawing.Image.FromFile(@&#8221;c:ggsggs Accessimagesmembers1.jpg&#8221;); int width = img.Width; int height = img.Height; &#8212; 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 &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=23073\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1973,1917],"tags":[],"class_list":["post-23073","post","type-post","status-publish","format-standard","hentry","category-c-misc","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10279,"url":"http:\/\/bangla.sitestree.com\/?p=10279","url_meta":{"origin":23073,"position":0},"title":"BetterCircleTest.java","author":"","date":"August 26, 2015","format":false,"excerpt":"********************** BetterCircleTest.java ********************** import java.awt.*; import java.applet.Applet; \/** Position circles down the diagonal so that their borders \u00a0*\u00a0 just touch. Illustrates that Java 1.1 lightweight \u00a0*\u00a0 components can be partially transparent. \u00a0* \u00a0 *\/ public class BetterCircleTest extends Applet { \u00a0 public void init() { \u00a0\u00a0\u00a0 setBackground(Color.lightGray); \u00a0\u00a0\u00a0 setLayout(null); \u00a0\u00a0\u00a0\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27215,"url":"http:\/\/bangla.sitestree.com\/?p=27215","url_meta":{"origin":23073,"position":1},"title":"BetterCircleTest.java #Programming Code Examples #Java\/J2EE\/J2ME #Advanced Swing","author":"Author-Check- Article-or-Video","date":"May 14, 2021","format":false,"excerpt":"********************** BetterCircleTest.java ********************** import java.awt.*; import java.applet.Applet; \/** Position circles down the diagonal so that their borders * just touch. Illustrates that Java 1.1 lightweight * components can be partially transparent. * *\/ public class BetterCircleTest extends Applet { public void init() { setBackground(Color.lightGray); setLayout(null); BetterCircle circle; int radius =\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10295,"url":"http:\/\/bangla.sitestree.com\/?p=10295","url_meta":{"origin":23073,"position":2},"title":"A demo providing multiple buttons to select a playing card-A Panel, using CardLayout control which of four possible subpanels, holding a different card, to display","author":"","date":"August 26, 2015","format":false,"excerpt":"####################### # CardDemo.java A demo providing multiple buttons to select a playing card. A Panel, using CardLayout control which of four possible subpanels, holding a different card, to display.Uses the following class and images: \u00a0\u00a0\u00a0 * CardPanel.java A Panel that displays a playing card. \u00a0\u00a0\u00a0 * ImageLabel.java A Canvas for\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27229,"url":"http:\/\/bangla.sitestree.com\/?p=27229","url_meta":{"origin":23073,"position":3},"title":"A demo providing multiple buttons to select a playing card-A Panel, using CardLayout control which of four possible subpanels, holding a different card, to display #Programming Code Examples #Java\/J2EE\/J2ME #Advanced Swing","author":"Author-Check- Article-or-Video","date":"May 14, 2021","format":false,"excerpt":"####################### # CardDemo.java A demo providing multiple buttons to select a playing card. A Panel, using CardLayout control which of four possible subpanels, holding a different card, to display.Uses the following class and images: * CardPanel.java A Panel that displays a playing card. * ImageLabel.java A Canvas for displaying images.\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10329,"url":"http:\/\/bangla.sitestree.com\/?p=10329","url_meta":{"origin":23073,"position":4},"title":"Position circles down the diagonal so that their borders","author":"","date":"August 26, 2015","format":false,"excerpt":"import java.awt.*; import java.applet.Applet; \/** Position circles down the diagonal so that their borders \u00a0*\u00a0 just touch. Illustrates that AWT components are \u00a0*\u00a0 rectangular and opaque. \u00a0 *\/ public class CircleTest2 extends Applet { \u00a0 public void init() { \u00a0\u00a0\u00a0 setBackground(Color.lightGray); \u00a0\u00a0\u00a0 setLayout(null); \/\/ Turn off layout manager. \u00a0\u00a0\u00a0 Circle\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10327,"url":"http:\/\/bangla.sitestree.com\/?p=10327","url_meta":{"origin":23073,"position":5},"title":"A Circle component built using a Canvas","author":"","date":"August 26, 2015","format":false,"excerpt":"import java.awt.*; \/** A Circle component built using a Canvas. \u00a0* \u00a0 *\/ public class Circle extends Canvas { \u00a0 private int width, height;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 \u00a0 public Circle(Color foreground, int radius) { \u00a0\u00a0\u00a0 setForeground(foreground); \u00a0\u00a0\u00a0 width = 2*radius; \u00a0\u00a0\u00a0 height = 2*radius; \u00a0\u00a0\u00a0 setSize(width, height); \u00a0 } \u00a0\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/23073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=23073"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/23073\/revisions"}],"predecessor-version":[{"id":78137,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/23073\/revisions\/78137"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=23073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=23073"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=23073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}