找回密码
 立即注册

QQ登录

只需一步,快速开始

[已处理] spread单元格设置

tingche
银牌会员   /  发表于:2013-10-8 09:29:00
11#
protected override void Render(HtmlTextWriter writer)

    {

        Table table = FpSpread1.FindControl("viewport") as Table;

        for (int row = 0; row < table.Rows.Count; row++)

        {

            for (int col = 0; col < table.Rows[row].Cells.Count; col++)

            {

                if (!string.IsNullOrWhiteSpace(FpSpread1.ActiveSheetView.Cells[row, col].Text))

                {

                    table.Rows[row].Cells[col].Attributes.Add("title", FpSpread1.ActiveSheetView.Cells[row, col].Text);

                }

            }

        }



        base.Render(writer);

    }

您好!请问 这种后台实现Tips Help的方式,spread前台用js是否能实现呢?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-10-8 10:16:00
12#
回复 11楼tingche的帖子

tingche 你好,

Spread 前台被渲染成 HTML table,单元格为 Table 中的 Cell ,所以可以通过 JS 操作 HTML Table Cell ,可以在前台改变或添加 title 值。
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-10-8 12:59:00
13#
您好!
spread 里 HTML Table Cell 没有唯一id,请问你们一般是如何定位特定的cell的?

另外,请教下:
      spread 单元格能否象EXCEL那样,只要文本超过了单元格长度,文本为英数字,就算没有空格,也能实现自动换行的效果?这个问题比较困扰,请帮助解决下,谢谢!
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-10-8 14:26:00
14#
回复 13楼tingche的帖子

tingche 你好,
是的,确实没有唯一 id,是通过行列索引来判断的:

  1.     <script type="text/javascript">

  2.         function Button1_onclick() {
  3.             var table = this.document.getElementById("FpSpread1_viewport");

  4.             //设置第二行第二列单元格的 note。
  5.             var cell = table.rows[1].cells[1].setAttribute("title", "test"); ;
  6.         }

  7.     </script>
复制代码
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-10-8 14:37:00
15#
谢谢,接着3#的问题,还想再请教下:



      spread 单元格能否象EXCEL那样,只要文本超过了单元格长度,文本为英数字,就算没有空格,也能实现自动换行的效果?这个问题比较困扰,请帮助解决下,谢谢!
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-10-8 14:39:00
16#
回复 15楼tingche的帖子

恩,这个问题刚才正在处理中。请测试以下代码:


  1.             //C#
  2.             FarPoint.Web.Spread.TextCellType tcell = new FarPoint.Web.Spread.TextCellType();
  3.             string Str;

  4.             Str = &quot;12345645645645645645456456456555555555555555555&quot;;
  5.             tcell.ShowEditor = true;
  6.             tcell.AllowWrap = true;
  7.             tcell.Multiline = true;
  8.             FpSpread1.ActiveSheetView.Cells[0, 0].CellType = tcell;
  9.             FpSpread1.ActiveSheetView.SetValue(0, 0, Str);

  10.             //VB.NET
  11.             Dim tcell As New FarPoint.Web.Spread.TextCellType()
  12.             Dim Str As String
  13.             Str=&quot;12345645645645645645456456456555555555555555555&quot;
  14.             tcell.AllowWrap=True
  15.              tcell.ShowEditor = True
  16.             tcell.Multiline = True

  17.             FpSpread1.ActiveSheetView.Cells(0,0).CellType=tcell
  18.             FpSpread1.ActiveSheetView.SetValue(0,0,Str)
复制代码
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-10-8 16:07:00
17#
谢谢,基本实现了!
        TextCellType 如何设定其高度?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-10-8 16:38:00
18#
回复 17楼tingche的帖子

请使用以下代码测试:

  1. protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }


  7.             //C#
  8.             FarPoint.Web.Spread.TextCellType tcell = new FarPoint.Web.Spread.TextCellType();
  9.             string Str;

  10.             Str = &quot;12345645645645645645456456456555555555555555555&quot;;
  11.             tcell.ShowEditor = true;
  12.             tcell.AllowWrap = true;
  13.             tcell.Multiline = true;
  14.             FpSpread1.ActiveSheetView.Cells[0, 0].CellType = tcell;
  15.             FpSpread1.ActiveSheetView.SetValue(0, 0, Str);
  16.             this.FpSpread1.ActiveSheetView.Rows[0].Height = 300;
  17.         }

  18.         protected override void Render(HtmlTextWriter writer)
  19.         {
  20.             Table table = this.FpSpread1.FindControl(&quot;viewport&quot;) as Table;

  21.             WebControl textarea = table.Rows[0].Cells[0].Controls[0] as WebControl;

  22.             textarea.Height = 200;
  23.             base.Render(writer);
  24.         }
复制代码
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-10-9 10:30:00
19#
紧接楼上的问题,我将cells的colunmspan=2,但是 textarea的宽度即使设置了width为两个单元格的宽度,但是界面显示还是一个单元格的宽度,查看了生成的前台html代码,如果后台设置了width宽度,html里有两个width属性,后面一个为自动生成的,请问怎么实现跨列?谢谢!

TextArea.png
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-10-9 11:13:00
20#
textarea.Attributes.CssStyle.Clear()
                    textarea.Height = 50
                    textarea.Width = 208

已经解决,谢谢,不用回了!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部