Excel行高与像素值,列宽与像素值之间的转换,绘制Excel像素画。
生活随笔
收集整理的這篇文章主要介紹了
Excel行高与像素值,列宽与像素值之间的转换,绘制Excel像素画。
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
private static float GetDpiX()
{try{using (Bitmap image = new Bitmap(1, 1)){using (Graphics graphics = Graphics.FromImage(image)){return graphics.DpiX;}}}catch{return 72;}
}
傳入像素numPixel
int numPixel = (int)numericUpDown1.Value; Bitmap image = ConvertToFormat(fileImage.Image, PixelFormat.Format24bppRgb); //Bitmap image = (Bitmap)fileImage.Image; g = pictureBox1.CreateGraphics();double rowHeight = (double)((float)numPixel * 72f / (float)GetDpiX());for (int i = 0; i < 100; i++) {double colWidth = Math.Round((numPixel < 12 ? (numPixel / 12.00) : (1 + ((numPixel - 12) / 7.00))), 2);int _numPixel = (int)Math.Round(colWidth < 1 ? colWidth * 12.0 : 12 + (colWidth - 1) * 7.00); Console.WriteLine(string.Format($"{numPixel} {colWidth} {_numPixel}"));numPixel = numPixel + 1;//double width = (double)((float)numPixel * 72f / (float)GetDpiX()); }?打印出100個與excel里面對比
?
| 1 | 0.08 |
| 2 | 0.17 |
| 3 | 0.25 |
| 4 | 0.33 |
| 5 | 0.42 |
| 6 | 0.5 |
| 7 | 0.58 |
| 8 | 0.67 |
| 9 | 0.75 |
| 10 | 0.83 |
| 11 | 0.92 |
| 12 | 1 |
| 13 | 1.14 |
| 14 | 1.29 |
| 15 | 1.43 |
| 16 | 1.57 |
| 17 | 1.71 |
| 18 | 1.86 |
| 19 | 2 |
| 20 | 2.14 |
| 21 | 2.29 |
| 22 | 2.43 |
| 23 | 2.57 |
| 24 | 2.71 |
| 25 | 2.86 |
| 26 | 3 |
| 27 | 3.14 |
| 28 | 3.29 |
| 29 | 3.43 |
| 30 | 3.57 |
| 31 | 3.71 |
| 32 | 3.86 |
| 33 | 4 |
| 34 | 4.14 |
| 35 | 4.29 |
| 36 | 4.43 |
| 37 | 4.57 |
| 38 | 4.71 |
| 39 | 4.86 |
| 40 | 5 |
| 41 | 5.14 |
| 42 | 5.29 |
| 43 | 5.43 |
| 44 | 5.57 |
| 45 | 5.71 |
| 46 | 5.86 |
| 47 | 6 |
| 48 | 6.14 |
| 49 | 6.29 |
| 50 | 6.43 |
| 51 | 6.57 |
| 52 | 6.71 |
| 53 | 6.86 |
| 54 | 7 |
| 55 | 7.14 |
| 56 | 7.29 |
| 57 | 7.43 |
| 58 | 7.57 |
| 59 | 7.71 |
| 60 | 7.86 |
| 61 | 8 |
| 62 | 8.14 |
| 63 | 8.29 |
| 64 | 8.43 |
| 65 | 8.57 |
| 66 | 8.71 |
| 67 | 8.86 |
| 68 | 9 |
| 69 | 9.14 |
| 70 | 9.29 |
| 71 | 9.43 |
| 72 | 9.57 |
| 73 | 9.71 |
| 74 | 9.86 |
| 75 | 10 |
| 76 | 10.14 |
| 77 | 10.29 |
| 78 | 10.43 |
| 79 | 10.57 |
| 80 | 10.71 |
| 81 | 10.86 |
| 82 | 11 |
| 83 | 11.14 |
| 84 | 11.29 |
| 85 | 11.43 |
| 86 | 11.57 |
| 87 | 11.71 |
| 88 | 11.86 |
| 89 | 12 |
| 90 | 12.14 |
| 91 | 12.29 |
| 92 | 12.43 |
| 93 | 12.57 |
| 94 | 12.71 |
| 95 | 12.86 |
| 96 | 13 |
| 97 | 13.14 |
| 98 | 13.29 |
| 99 | 13.43 |
| 100 | 13.57 |
總結
以上是生活随笔為你收集整理的Excel行高与像素值,列宽与像素值之间的转换,绘制Excel像素画。的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 论文排版和作图
- 下一篇: fastadmin 数据导出,设置exc