生成下拉框

This script is only for Chinese mainland users. The script function is to help Beijing Construction Research Company set up excel forms with one click

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/430525/959234/%E7%94%9F%E6%88%90%E4%B8%8B%E6%8B%89%E6%A1%86.js

  1. // ==UserScript==
  2. // @name 生成下拉框
  3. // @namespace coderWyh
  4. // @version 1.0.2
  5. // @description This script is only for Chinese mainland users. The script function is to help Beijing Construction Research Company set up excel forms with one click
  6. // @author coderWyh
  7. // @match http://www.gczl360.com:8084/Admin/ZLKGL/Template*
  8. // @require https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. axios.post(BASEURL+'jky/value/getCodeValue/'+autoSetButtonCode)
  15. .then(response =>{
  16. if (response.data.success) {
  17. $(".record_box>.slimScrollDiv").append("<button style='position:absolute;top:0%;left:2%;background-color:peachpuff;border:1px solid;text-transform: uppercase;font-size: 14px;padding: 5px 10px;font-weight: 300;' class='xlk'>下拉框</button>")
  18. $('.xlk').on('click', function() {
  19. spread.suspendPaint();
  20. var sheet = spread.getActiveSheet()
  21. let style = new GC.Spread.Sheets.Style()
  22. style.borderBottom = new GC.Spread.Sheets.LineBorder("#000000", GC.Spread.Sheets.LineStyle.thin);
  23. style.borderRight = new GC.Spread.Sheets.LineBorder("#000000", GC.Spread.Sheets.LineStyle.thin);
  24. style.borderLeft = new GC.Spread.Sheets.LineBorder("#000000", GC.Spread.Sheets.LineStyle.thin);
  25. style.borderTop = new GC.Spread.Sheets.LineBorder("#000000", GC.Spread.Sheets.LineStyle.thin);
  26. style.cellButtons = [{
  27. imageType: GC.Spread.Sheets.ButtonImageType.dropdown,
  28. command: 'openList',
  29. useButtonStyle: false,
  30. visibility: GC.Spread.Sheets.ButtonVisibility.onSelected
  31. }];
  32. style.dropDowns = [{
  33. type: GC.Spread.Sheets.DropDownType.list,
  34. option: {
  35. items: [{
  36. text: ' ',
  37. value: ' '
  38. },
  39. {
  40. text: '√',
  41. value: '√'
  42. },
  43. {
  44. text: '×',
  45. value: '×'
  46. },
  47. {
  48. text: '/',
  49. value: '/'
  50. },
  51. {
  52. text: '%',
  53. value: '%'
  54. }],
  55. multiSelect: false,
  56. valueType: 0,
  57. }
  58. }];
  59. let selections = sheet.getSelections()
  60. let beginRowIndex = selections[0].row
  61. let beginColIndex = selections[0].col
  62. let endRowIndex = selections[0].rowCount
  63. for (let i = 0; i < endRowIndex; i++) {
  64. if(sheet.getText(beginRowIndex + i, beginColIndex)===''||sheet.getText(beginRowIndex + i, beginColIndex)===null) {
  65. sheet.setStyle(beginRowIndex + i, beginColIndex, style);
  66. }
  67. }
  68. spread.resumePaint();
  69. layer.msg("下拉框设置成功,已自动跳过有值的单元格", {
  70. time: 1300
  71. });
  72. });
  73. }
  74.  
  75. }).catch (error => {
  76.  
  77. })
  78.  
  79. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址