找回密码
 立即注册

QQ登录

只需一步,快速开始

lqs27
论坛元老   /  发表于:2014-1-21 10:30  /   查看:7009  /  回复:6
WINFORM Spread 控件表单的默认字体大小及像素是多少?
如果是'9号 宋体',两列文本:"123456789"和'一二三四五六七八九',它们的每个字,所占的像素是多少(决对值)?
汉字是不是绝对等于数字的2倍速像素?
我想知道合并后行通过计算能放下多少个数字或英文字符或汉字?
想确认下.

QQ截图20140121100513.jpg (10.19 KB, 下载次数: 524)

6 个回复

倒序浏览
roger.wang
社区贡献组   /  发表于:2014-1-22 09:22:00
沙发
回复 1楼lqs27的帖子

您好,问题回复如下:
1 默认字体和大小为:
  Microsoft Sans Serif  8.25
   通过这个代码查看
  1. Font ooo = fpSpread1.Font;
复制代码


2 查询'9号 宋体'对应的2行文字像素,请通过lable控件---autoSize=true
  如

  1.             label1.Font = new System.Drawing.Font("宋体", 9); //9 磅
  2.         label1.Text = "123456789";
  3.             int ww = label1.Width; //59

  4.             label2.Font = new System.Drawing.Font("宋体", 9);
  5.             label2.Text = "一二三四五六七八九";
  6.             int ww2 = label2.Width; //113
复制代码


从实验结果看,汉字是不是数字的2倍速像素。
3 Spread默认单元格宽、高

  1. //60 ppixels
  2.             float w = this.fpSpread1.ActiveSheet.Cells[0, 0].Column.Width;

  3.             //20 pixels
  4.             float h = this.fpSpread1.ActiveSheet.Cells[0, 0].Row.Height;
复制代码


最后一个问题没看清楚:“我想知道合并后行通过计算能放下多少个数字或英文字符或汉字?
回复 使用道具 举报
lqs27
论坛元老   /  发表于:2014-1-22 10:34:00
板凳
有出入,FP表格中,上图中54:108 正好2倍.这是怎么回事
我一直问的是在FP中测试结果
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-1-23 09:18:00
地板
回复 3楼lqs27的帖子

:Z
抱歉,这个我需要咨询一下产品团队,请您稍等两天。
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-1-24 16:58:00
5#
回复 3楼lqs27的帖子

让您久等了  

FP中和.net测量的文字宽度大小有出入,是因为有span、padding等。

可通过函数GetPreferredColumnWidth测量列实际占文字内容宽度。

  1.         //
  2.         // Summary:
  3.         //     Gets the width of the widest cell (based on text content) in the specified
  4.         //     column on this sheet.
  5.         //
  6.         // Parameters:
  7.         //   column:
  8.         //     Column index
  9.         //
  10.         //   ignoreHeaders:
  11.         //     Whether to ignore column header cells
  12.         //
  13.         //   ignoreSpans:
  14.         //     Whether to ignore spans
  15.         //
  16.         //   excludeWordWrap:
  17.         //     Whether to exclude cells with wrapped contents
  18.         //
  19.         // Remarks:
  20.         //     A cell has wrapped contents (text that wraps to multiple lines) when the
  21.         //     renderer in the composite style for the cell implements IWordWrapSupport
  22.         //     interface and its WordWrap property returns true.
  23.         public float GetPreferredColumnWidth(int column, bool ignoreHeaders, bool ignoreSpans, bool excludeWordWrap);
复制代码
回复 使用道具 举报
lqs27
论坛元老   /  发表于:2014-1-25 15:29:00
6#
好的,谢谢
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-1-26 09:39:00
7#
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部