Formula to convert .NET pixels to Excel width in OpenXML format

前端 未结 3 529
故里飘歌
故里飘歌 2021-02-13 04:16

I have spent many hours trying to determine a formula to convert .NET pixels to an Excel column width using the OpenXML format. I am using EPPlus to generate xmls documents. I\'

3条回答
  •  误落风尘
    2021-02-13 04:47

    The formula that i came up with to convert pixel width to Excel width is

        private double PixelWidthToExcel(int pixels)
        {
            var tempWidth = pixels * 0.14099;
            var correction = (tempWidth / 100) * -1.30;
    
            return tempWidth - correction;
        }
    

    To me it always gives exact value conversion.

    And the formula for height

        private double PixelHeightToExcel(int pixels)
        {
            return pixels * 0.75;
        }
    

提交回复
热议问题