找回密码
 立即注册

QQ登录

只需一步,快速开始

guigui

注册会员

8

主题

16

帖子

142

积分

注册会员

积分
142
guigui
注册会员   /  发表于:2016-10-17 19:40  /   查看:4290  /  回复:5
sheet.setValue(r, dc, dtresult[r].ID);
sheet.setText(r, dc, dtresult[r].Value);
但是最后使用getValue 得到的 和 getText结果总是一样,请问这是为什么?

5 个回复

倒序浏览
Alice
社区贡献组   /  发表于:2016-10-18 11:00:13
沙发
谢谢您的反馈。
单元格的Value指的是和数据源相关的值,而Text指的是包含格式的文字。
从您的代码来看,您对这个的意思理解有误,感觉您需要使用的是一个对应关系。
您可以通过如下代码来理解Text和Value
  1. $(document).ready(function () {
  2.      var spread = new GcSpread.Sheets.Spread($("#ss").get(0),{sheetCount:3});
  3.      var sheet = spread.getActiveSheet();
  4.      sheet.getCell(0, 0).formatter("0.00_);(0.00)");
  5.      sheet.getCell(1, 0).formatter("0.00_);(0.00)");
  6.      sheet.getCell(0, 1).formatter("0.00_);(0.00)");
  7.      sheet.getCell(1, 1).formatter("0.00_);(0.00)");

  8.      //Set values to Text property
  9.      sheet.getCell(0, 0).text(10);
  10.      //Set values by calling SetText method
  11.      sheet.setText(1, 0, 10);

  12.      //Set values to Value property.
  13.      sheet.getCell(0, 1).value(10);
  14.      //Set values by calling SetValue method.
  15.      sheet.setValue(1, 1, 10);

  16.      $("#button1").click(function(){
  17.          alert("Obtaining cell values by referring to Text property: " + sheet.getCell(0, 0).text() + "\n" +
  18.              "Obtaining cell values by calling GetText method: " + sheet.getText(1, 0) + "\n" +
  19.              "Obtaining cell values by referring to Value property: " + sheet.getCell(0, 1).value() + "\n" +
  20.              "Obtaining cell values by calling GetValue method: " + sheet.getValue(1, 1));
  21.      });
  22. });
复制代码
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
guigui
注册会员   /  发表于:2016-10-18 11:08:16
板凳
我这边的需求是:我想保存同一列的两个不同属性,请问如何实现。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-10-18 16:18:25
地板
本帖最后由 dexteryao 于 2016-10-18 16:25 编辑

您可以把其他参数保存在tag中,或者你需要通过自定义单元格实现object valuehttp://demo.gcpowertools.com.cn/ ... ples/customCellType

评分

参与人数 1满意度 +5 收起 理由
guigui + 5 赞一个!

查看全部评分

回复 使用道具 举报
guigui
注册会员   /  发表于:2016-10-18 17:12:45
5#
好的,谢谢。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-10-19 08:54:10
6#
应该的
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部