回复 1楼huchunyan的帖子
请通过以下代码转换:
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- this.gcSpreadSheet1.ActiveSheet.Cells[0, 0].FontSize = UnitHelper.PointToPixel(11);
- this.gcSpreadSheet1.ActiveSheet.Cells[0, 0].Text = "测试";
- }
- }
- internal static class UnitHelper
- {
- private static double? _dpi;
- private static readonly double PointsPerInch = 72;
- public static double PointToPixel(double point)
- {
- return point * GetDPI() / PointsPerInch;
- }
- public static double PixelToPoint(double pixel)
- {
- return pixel * PointsPerInch / GetDPI();
- }
- public static double GetDPI()
- {
- if (_dpi.HasValue)
- return _dpi.Value;
- else
- {
- _dpi = GetSystemDPI();
- return _dpi.Value;
- }
- }
- private static double GetSystemDPI()
- {
- return 96; //Look like excel always use DPI=96.
- }
- }
复制代码 |