找回密码
 立即注册

QQ登录

只需一步,快速开始

爱迪生

超级版主

55

主题

65

帖子

1384

积分

超级版主

Rank: 8Rank: 8

积分
1384
爱迪生
超级版主   /  发表于:2022-9-14 18:43  /   查看:1801  /  回复:0
本帖最后由 爱迪生 于 2022-9-15 12:07 编辑

SpreadJS  v15.2支持名称框组件。
1.UI行为:
image.png932837829.png
1.1名称框由“选择器”和“下拉菜单”组成
1.1.1选择器:显示选择
选择更改时,显示更改选择:
image.png273482360.png
设置选择后,显示活动单元格:
image.png53415221.png
选择图形时,显示图形名称:
image.png489954223.png
当 selection 等于命名范围或表名时,显示名称:
image.png783437499.png
1.1.2下拉列表:显示自定义名称列表
自定义名称列表包括以下内容:
  • 工作簿自定义名称和表达式类型等于GC.Spread.CalcEngine.ExpressionType.reference
  • 活动工作表自定义名称和表达式类型等于GC.Spread.CalcEngine.ExpressionType.reference
  • 所有工作表的所有表的名称

自定义名称列表:显示命名范围,如果单击项目,导航到命名范围
image.png559080199.png
2.支持的主题
SpreadJS:
image.png515453490.png
Excel2013白色:
image.png854829406.png
Excel2013浅灰色:
image.png913320617.png
Excel2013深灰色:
image.png629565734.png
Excel2016多彩:
image.png745823058.png
Excel2016深灰色:
image.png935133972.png
Excel2016黑色:
image.png686304626.png
3.API:
GC.Spread.Sheets.NameBox:
  1. /**
  2. * Gets the NameBox instance by the host element.
  3. * @param {HTMLElement|string} host The host element or the host element id.
  4. * @returns {GC.Spread.Sheets.NameBox.NameBox} The NameBox instance.
  5. * @example
  6. * var spread = new GC.Spread.Sheets.Workbook("ss");
  7. * var nameBox = new GC.Spread.Sheets.NameBox.NameBox('nameBox', spread);
  8. * var nameBoxInstance = GC.Spread.Sheets.NameBox.findControl('nameBox');
  9. */
  10. findControl(host: HTMLElement|string): GC.Spread.Sheets.NameBox.NameBox
复制代码
GC.Spread.Sheets.NameBox.NameBox:
  1. /**
  2. * Represents name box.
  3. * @class
  4. * @param {HTMLElement|string} host The DOM Element.
  5. * @param {GC.Spread.Sheets.Workbook} spread The workbook which the namebox bound.
  6. * @param {GC.Spread.Sheets.NameBox.INameBoxOptions} [options] options of the name box.
  7. */
  8. constructor (host: HTMLElement | string, workbook: GC.Spread.Sheets.Workbook, options?: GC.Spread.Sheets.NameBox.INameBoxOptions)

  9. /**
  10. * get the NameBox host element.
  11. * @example
  12. * var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
  13. * var nameBox = new GC.Spread.Sheets.NameBox.NameBox(document.getElementById('nameBox'), spread);
  14. * var host = nameBox.getHost();
  15. */
  16. function getHost(): HTMLElement

  17. /**
  18. * refresh the NameBox and sync the name box value to the work sheet selection.
  19. * @example
  20. * var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
  21. * var nameBox = new GC.Spread.Sheets.NameBox.NameBox(document.getElementById('nameBox'), spread);
  22. * nameBox.refresh();
  23. */
  24. function refresh(): void

  25. /**
  26. * Dispose the NameBox and unbind all events.
  27. * @example
  28. * var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
  29. * var nameBox = new GC.Spread.Sheets.NameBox.NameBox(document.getElementById('nameBox'), spread);
  30. * // do something
  31. * nameBox.dispose();
  32. */
  33. function dispose(): void
复制代码
名称框选项GC.Spread.Sheets.NameBox.INameBox 选项:
  1. interface INameBoxOptions {
  2.     /**
  3.      * Indicates the drop down list element max height.
  4.      * the default value is 500(px).
  5.      */
  6.     dropDownMaxHeight?: number;
  7.     /**
  8.      * Indicates whether enable add custom name when input a name which is not existed to the selector.
  9.      * the default value is true.
  10.      */
  11.     enableAddCustomName?: boolean;
  12.     /**
  13.      * Indicates whether enable navigate to the named range or drawing item when input its name or click on custom list item.
  14.      * the default value is true.
  15.      */
  16.     enableNavigateToRange?: boolean;
  17.     /**
  18.      * Indicates whether show the custom name list dropdown indicator.
  19.      * the default value is true.
  20.      */
  21.     showCustomNameList?: boolean;
复制代码
4.示例代码:
4.1设置名称框选项
4.1.1创建名称框时设置:
  1. var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
  2. var namebox = new GC.Spread.Sheets.NameBox.NameBox(document.getElementById("namebox"), spread, {
  3.     dropDownMaxHeight: 200
  4. });
复制代码
4.1.2使用名称框实例设置选项:
  1. namebox.options.enableAddCustomName = false.
复制代码
4.2示例:
  1. var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
  2. var nameBox = new GC.Spread.Sheets.NameBox.NameBox(document.getElementById('nameBox'), spread, {
  3.   showCustomNameList: false
  4. });
  5. nameBox.refresh();

  6. spread.destroy();
  7. nameBox.dispose();
复制代码






0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部