类似动态电子表格 数据网格 jExcel

  • 源码大小:102.19KB
  • 所需积分:1积分
  • 源码编号:19JP-3165
  • 浏览次数:1076次
  • 最后更新:2023年05月13日
  • 所属栏目:表格
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

jExcel是一个强大的jQuery和Vanilla JavaScript插件,它可以让您从本地JS数据甚至JSON、CSV、XSLX文件动态生成类似CRUD的电子表格数据网格(表)。

易于与任何第三方插件集成数据操作插件,如输入掩码、货币格式、键值下拉、颜色选择器等。还附带了一个onchange处理程序,它将在电子表格中的每一次更改时启动。

请注意,最新的jExcel(v3.0+)已经放弃了对jQuery的支持。您可以将其用作普通的JavaScript库。在此处下载。

参见:

  • JavaScript中的10个最佳数据表/网格系统

目录:

  • 作为Vanilla JavaScript插件
  • 作为jQuery插件

如何使用它(v4+,Vanilla JS版本):

1.将jExcel和jSuites导入到文档中。

  1. <link rel="stylesheet" href="/path/to/jsuites.css" />
  2. <link rel="stylesheet" href="/path/to/jexcel.css" />
  3. <script src="/path/to/jsuites.js"></script>
  4. <script src="/path/to/jexcel.js"></script>

2.创建一个空的DIV元素来保存电子表格。

  1. <div id="demo"></div>

3.根据您提供的数据集生成电子表格。。

  1. // from JS arrays
  2. jexcel(document.getElementById('demo'), {
  3. data: [
  4. // data here
  5. ];
  6. columns:[
  7. // columns data here
  8. ]
  9. });
  10.  
  11. // from a JSON file
  12. jexcel(document.getElementById('demo'), {
  13. url:'data.json',
  14. columns:[
  15. // columns data here
  16. ]
  17. });
  18.  
  19. // from a CSV file
  20. jexcel(document.getElementById('demo'), {
  21. csv:'demo.csv',
  22. csvHeaders:true,
  23. columns:[
  24. // columns data here
  25. ]
  26. });

4.具有默认值的所有可能选项。

  1. // External data
  2. url:null,
  3. // Data
  4. data:null,
  5. // Copy behavior
  6. copyCompatibility:false,
  7. root:null,
  8. // Rows and columns definitions
  9. rows:[],
  10. columns:[],
  11. // Deprected legacy options
  12. colHeaders:[],
  13. colWidths:[],
  14. colAlignments:[],
  15. nestedHeaders:null,
  16. // Column width that is used by default
  17. defaultColWidth:50,
  18. defaultColAlign:'center',
  19. // Spare rows and columns
  20. minSpareRows:0,
  21. minSpareCols:0,
  22. // Minimal table dimensions
  23. minDimensions:[0,0],
  24. // Allow Export
  25. allowExport:true,
  26. // @type {boolean} - Include the header titles on download
  27. includeHeadersOnDownload:false,
  28. // @type {boolean} - Include the header titles on copy
  29. includeHeadersOnCopy:false,
  30. // Allow column sorting
  31. columnSorting:true,
  32. // Allow column dragging
  33. columnDrag:false,
  34. // Allow column resizing
  35. columnResize:true,
  36. // Allow row resizing
  37. rowResize:false,
  38. // Allow row dragging
  39. rowDrag:true,
  40. // Allow table edition
  41. editable:true,
  42. // Allow new rows
  43. allowInsertRow:true,
  44. // Allow new rows
  45. allowManualInsertRow:true,
  46. // Allow new columns
  47. allowInsertColumn:true,
  48. // Allow new rows
  49. allowManualInsertColumn:true,
  50. // Allow row delete
  51. allowDeleteRow:true,
  52. // Allow deleting of all rows
  53. allowDeletingAllRows:false,
  54. // Allow column delete
  55. allowDeleteColumn:true,
  56. // Allow rename column
  57. allowRenameColumn:true,
  58. // Allow comments
  59. allowComments:false,
  60. // Global wrap
  61. wordWrap:false,
  62. // Image options
  63. imageOptions: null,
  64. // CSV source
  65. csv:null,
  66. // Filename
  67. csvFileName:'jexcel',
  68. // Consider first line as header
  69. csvHeaders:true,
  70. // Delimiters
  71. csvDelimiter:',',
  72. // First row as header
  73. parseTableFirstRowAsHeader:false,
  74. parseTableAutoCellType:false,
  75. // Disable corner selection
  76. selectionCopy:true,
  77. // Merged cells
  78. mergeCells:{},
  79. // Create toolbar
  80. toolbar:null,
  81. // Allow search
  82. search:false,
  83. // Create pagination
  84. pagination:false,
  85. paginationOptions:null,
  86. // Full screen
  87. fullscreen:false,
  88. // Lazy loading
  89. lazyLoading:false,
  90. loadingSpin:false,
  91. // Table overflow
  92. tableOverflow:false,
  93. tableHeight:'300px',
  94. tableWidth:null,
  95. // Meta
  96. meta: null,
  97. // Style
  98. style:null,
  99. // Execute formulas
  100. parseFormulas:true,
  101. autoIncrement:true,
  102. autoCasting:true,
  103. // Security
  104. secureFormulas:true,
  105. stripHTML:true,
  106. // Filters
  107. filters:false,
  108. footers:null,
  109. // Global event dispatcher
  110. onevent:null,
  111. // Persistance
  112. persistance:false,
  113. // Customize any cell behavior
  114. updateTable:null,
  115. // Detach the HTML table when calling updateTable
  116. detachForUpdates: false,
  117. freezeColumns:null,

5.回调函数。

  1. onundo: function(instance, historyRecord){
  2. // do something
  3. },
  4. onredo: function(instance, historyRecord){
  5. // do something
  6. },
  7. onload: function(instance, historyRecord){
  8. // do something
  9. },
  10. onchange: function(instance, cell, x, y, value){
  11. // do something
  12. },
  13. onbeforechange: function(instance, cell, x, y, value){
  14. // do something
  15. },
  16. onafterchanges: function(instance, records){
  17. // do something
  18. },
  19. onbeforeinsertrow: function(instance, rowNumber, numOfRows, insertBefore){
  20. // do something
  21. },
  22. oninsertrow: function(instance, rowNumber, numOfRows, rowRecords, insertBefore){
  23. // do something
  24. },
  25. onbeforeinsertcolumn: function(instance, columnNumber, numOfColumns, insertBefore){
  26. // do something
  27. },
  28. oninsertcolumn: function(instance, columnNumber, numOfColumns, historyRecords, insertBefore){
  29. // do something
  30. },
  31. onbeforedeleterow: function(instance, rowNumber, numOfRows){
  32. // do something
  33. },
  34. ondeleterow: function(instance, rowNumber, numOfRows, rowRecords){
  35. // do something
  36. },
  37. onbeforedeletecolumn: function(instance, columnNumber, numOfColumns){
  38. // do something
  39. },
  40. ondeletecolumn: function(instance, columnNumber, numOfColumns, historyRecords){
  41. // do something
  42. },
  43. onmoverow: function(instance, from, to){
  44. // do something
  45. },
  46. onmovecolumn: function(instance, from, to){
  47. // do something
  48. },
  49. onresizerow: function(instance, cell, width){
  50. // do something
  51. },
  52. onresizecolumn: function(instance, cell, width){
  53. // do something
  54. },
  55. onsort: function(instance, cellNum, order){
  56. // do something
  57. },
  58. onselection: function(instance, x1, y1, x2, y2, origin){
  59. // do something
  60. },
  61. onpaste: function(instance, data){
  62. // do something
  63. },
  64. onbeforepaste: function(instance, data, x, y){
  65. // do something
  66. },
  67. onmerge: function(instance, cellName, colspan, rowspan){
  68. // do something
  69. },
  70. onfocus: function(instance){
  71. // do something
  72. },
  73. onblur: function(instance){
  74. // do something
  75. },
  76. onchangeheader: function(instance, column, oldValue, newValue){
  77. // do something
  78. },
  79. oneditionstart: function(instance, cell, x, y){
  80. // do something
  81. },
  82. oneditionend: function(instance, cell, x, y, value, save){
  83. // do something
  84. },
  85. onchangestyle: function(instance, o, k, v){
  86. // do something
  87. },
  88. onchangemeta: function(instance, o, k, v){
  89. // do something
  90. },
  91. onchangepage: function(instance, pageNumber, oldPage){
  92. // do something
  93. },
  94. onbeforesave: function(instance, obj, data){
  95. // do something
  96. },
  97. onsave: function(instance, obj, data){
  98. // do something
  99. },

6.对插件进行本地化。

  1. text:{
  2. noRecordsFound: 'No records found',
  3. showingPage: 'Showing page {0} of {1} entries',
  4. show: 'Show ',
  5. search: 'Search',
  6. entries: ' entries',
  7. columnName: 'Column name',
  8. insertANewColumnBefore: 'Insert a new column before',
  9. insertANewColumnAfter: 'Insert a new column after',
  10. deleteSelectedColumns: 'Delete selected columns',
  11. renameThisColumn: 'Rename this column',
  12. orderAscending: 'Order ascending',
  13. orderDescending: 'Order descending',
  14. insertANewRowBefore: 'Insert a new row before',
  15. insertANewRowAfter: 'Insert a new row after',
  16. deleteSelectedRows: 'Delete selected rows',
  17. editComments: 'Edit comments',
  18. addComments: 'Add comments',
  19. comments: 'Comments',
  20. clearComments: 'Clear comments',
  21. copy: 'Copy...',
  22. paste: 'Paste...',
  23. saveAs: 'Save as...',
  24. about: 'About',
  25. areYouSureToDeleteTheSelectedRows: 'Are you sure to delete the selected rows?',
  26. areYouSureToDeleteTheSelectedColumns: 'Are you sure to delete the selected columns?',
  27. thisActionWillDestroyAnyExistingMergedCellsAreYouSure: 'This action will destroy any existing merged cells. Are you sure?',
  28. thisActionWillClearYourSearchResultsAreYouSure: 'This action will clear your search results. Are you sure?',
  29. thereIsAConflictWithAnotherMergedCell: 'There is a conflict with another merged cell',
  30. invalidMergeProperties: 'Invalid merged properties',
  31. cellAlreadyMerged: 'Cell already merged',
  32. noCellsSelected: 'No cells selected',
  33. },

7.API方法。

  1. // Get the full or partial table data
  2. // @Param boolan onlyHighlighedCells - Get only highlighted cells
  3. myTable.getData([bool]);
  4.  
  5. // Get the full or partial table data in JSON format
  6. // @Param boolan onlyHighlighedCells - Get only highlighted cells
  7. myTable.getData([bool]);
  8.  
  9. // Get the data from one row by number
  10. // @Param integer rowNumber - Row number
  11. myTable.getRowData([int]);
  12.  
  13. // Get the data from one column by number
  14. // @Param integer columnNumber - Column number
  15. myTable.getColumnData([int]);
  16.  
  17. // Set the data from one column by number
  18. // @Param integer columnNumber - Column number
  19. myTable.setColumnData([int], [array]);
  20.  
  21. // Update the table data
  22. // @Param json newData - New json data, null will reload what is in memory.
  23. myTable.setData([json]);
  24.  
  25. // Merge cells
  26. // @Param string columnName - Column name, such as A1.
  27. // @Param integer colspan - Number of columns
  28. // @Param integer rowspan - Number of rows
  29. myTable.setMerge([string], [int], [int]);
  30.  
  31. // Get merged cells properties
  32. // @Param string columnName - Column name, such as A1.
  33. myTable.getMerge([string]);
  34.  
  35. // Remove merged
  36. // @Param string columnName - Column name, such as A1.
  37. myTable.removeMerge([string]);
  38.  
  39. // Destroy merged by column name
  40. // destroyMerged: Destroy all merged cells
  41. myTable.destroyMerge();
  42.  
  43. // Get current cell DOM
  44. // @Param string columnName - str compatible with excel, or as object.
  45. myTable.getCell([string]);
  46.  
  47. // Get current cell DOM innerHTML
  48. // @Param string columnName - str compatible with excel, or as object.
  49. myTable.getLabel([string]);
  50.  
  51. // Get current cell value
  52. // @Param mixed cellIdent - str compatible with excel, or as object.
  53. myTable.getValue([string]);
  54.  
  55. // Get value from coords
  56. // @Param integer x
  57. // @Param integer y
  58. myTable.getValueFromCoords([integer], [integer]);
  59.  
  60. // Change the cell value
  61. // @Param mixed cellIdent - str compatible with excel, or as object.
  62. // @Param string Value - new value for the cell
  63. myTable.setValue([string], [string]);
  64.  
  65. // Set value from coords
  66. // @Param integer x
  67. // @Param integer y
  68. // @Param string Value - new value for the cell
  69. // @Param bool force - update readonly columns
  70. myTable.getValueFromCoords([integer], [integer], [string], [bool]);
  71.  
  72. // Reset the table selection
  73. // @Param boolean executeBlur - execute the blur from the table
  74. myTable.resetSelection([bool]);
  75.  
  76. // Select cells
  77. // @Param object startCell - cell object
  78. // @Param object endCell - cell object
  79. // @Param boolean ignoreEvents - ignore onselection event
  80. myTable.updateSelection([cell], [cell], true);
  81.  
  82. // Select cells
  83. // @Param integer x1
  84. // @Param integer y1
  85. // @Param integer x2
  86. // @Param integer y2
  87. myTable.updateSelectionFromCoords([integer], [integer], [integer], [integer]);
  88.  
  89. // Get the current column width
  90. // @Param integer columnNumber - column number starting on zero
  91. myTable.getWidth([integer]);
  92.  
  93. // Change column width
  94. // @Param integer columnNumber - column number starting on zero
  95. // @Param string newColumnWidth - New column width
  96. myTable.setWidth([integer], [integer]);
  97.  
  98. // Get the current row height
  99. // @Param integer rowNumber - row number starting on zero
  100. myTable.getHeight([integer]);
  101.  
  102. // Change row height
  103. // @Param integer rowNumber - row number starting on zero
  104. // @Param string newRowHeight- New row height
  105. myTable.setHeight([integer], [integer]);
  106.  
  107. // Get the current header by column number
  108. // @Param integer columnNumber - Column number starting on zero
  109. myTable.getHeader([integer]);
  110.  
  111. // Get all header titles
  112. myTable.getHeaders();
  113.  
  114. // Change header by column
  115. // @Param integer columnNumber - column number starting on zero
  116. // @Param string columnTitle - New header title
  117. myTable.setHeader([integer], [string]);
  118.  
  119. // Get table or cell style
  120. // @Param mixed - cell identification or null for the whole table.
  121. myTable.getStyle([string]);
  122.  
  123. // Set cell(s) CSS style
  124. // @Param mixed - json with whole table style information or just one cell identification. Ex. A1.
  125. // @param k [optional]- CSS key
  126. // @param v [optional]- CSS value
  127. myTable.setSyle([object], [string], [string]);
  128.  
  129. // Remove all style from a cell
  130. // @Param string columnName - Column name, example: A1, B3, etc
  131. myTable.resetStyle([string]);
  132.  
  133. // Get cell comments
  134. // @Param mixed - cell identification or null for the whole table.
  135. myTable.getComments([string]);
  136.  
  137. // Set cell comments
  138. // @Param cell - cell identification
  139. // @Param text - comments
  140. myTable.setComments([string], [string]);
  141.  
  142. // Reorder a column asc or desc
  143. // @Param boolean sortType - Zero will toggle current option, one for desc, two for asc
  144. myTable.orderBy([integer], [boolean]);
  145.  
  146. // Get table definitions
  147. myTable.getConfig();
  148.  
  149. // Add a new column
  150. // @param mixed - num of columns to be added or data to be added in one single column
  151. // @param int columnNumber - number of columns to be created
  152. // @param boolean insertBefore
  153. // @param object properties - column properties
  154. myTable.insertColumn([mixed], [integer], [boolean], [object]);
  155.  
  156. // Remove column by number
  157. // @Param integer columnNumber - Which column should be excluded starting on zero
  158. // @param integer numOfColumns - number of columns to be excluded from the reference column myTable.deleteColumn([integer], [integer]);
  159.  
  160. // change the column position
  161. // @Param integer columnPosition
  162. // @Param integer newColumnPosition
  163. myTable.moveColumn([integer], [integer]);
  164.  
  165. // Add a new row
  166. // @Param mixed - number of blank lines to be insert or a single array with the data of the new row
  167. // @Param integer rowNumber - reference row number
  168. // @param boolean insertBefore
  169. myTable.insertRow([mixed], [integer], [boolean]);
  170.  
  171. // Remove row by number
  172. // @Param integer rowNumber - Which row should be excluded starting on zero
  173. // @Param integer numOfRows - number of lines to be excluded
  174. myTable.deleteRow([integer], [integer]);
  175.  
  176. // Change the row position
  177. // @Param integer rowPosition
  178. // @Param integer newRowPosition
  179. myTable.moveRow([integer], [integer]);
  180.  
  181. // Get the current data as a CSV file
  182. myTable.download();
  183.  
  184. // Get the table or cell meta information
  185. // @Param mixed - cell identification or null for the whole table.
  186. myTable.getMeta([string]);
  187.  
  188. // Set the table or cell meta information
  189. // @Param mixed - json with whole table meta information.
  190. myTable.setMeta([mixed]);
  191.  
  192. // Toogle table fullscreen mode
  193. // @Param boolan fullscreen - define fullscreen status as true or false
  194. myTable.fullscreen([bool]);
  195.  
  196. // Get the selected rows
  197. // @Param boolan asIds - Get the rowNumbers or row DOM elements
  198. myTable.getSelectedRows([bool]);
  199.  
  200. // Get the selected columns
  201. // @Param boolan asIds - Get the colNumbers or row DOM elements
  202. myTable.getSelectedColumns([bool]);
  203.  
  204. // Show column of index numbers
  205. myTable.showIndex();
  206.  
  207. // Hide column of index numbers
  208. myTable.hideIndex();
  209.  
  210. // Search in the table, only if directive is enabled during inialization.
  211. // @Param string - Search for word
  212. myTable.search([string]);
  213.  
  214. // Reset search table
  215. myTable.resetSearch();
  216.  
  217. // Which page showing on jExcel - Valid only when pagination is true.
  218. myTable.whichPage();
  219.  
  220. // Go to page number- Valid only when pagination is true.
  221. // @Param integer - Go to page number
  222. myTable.page([integer]);
  223.  
  224. // Undo last changes
  225. myTable.undo();
  226.  
  227. // Redo changes
  228. myTable.redo();

如何使用它(v2.x,jQuery版本):

1.在网页中添加对jQuery库和jQuery jExcel插件的JS和CSS文件的引用。

  1. <link href="dist/css/jquery.jexcel.css" rel="stylesheet">
  2. <script src="//code.jquery.com/jquery.min.js"></script>
  3. <script src="dist/js/jquery.jexcel.js"></script>

2.根据您的需要加载扩展。所有可能的扩展:

  • 下拉列表
  • 日历选择器
  • CSV文件
  • 公式
  1. <!-- Dropdown -->
  2. <link rel="stylesheet" href="dist/css/jquery.jdropdown.min.css" />
  3. <script src="dist/js/jquery.jdropdown.js"></script>
  4.  
  5. <!-- Calendar picker -->
  6. <link rel="stylesheet" href="dist/css/jquery.jcalendar.css" />
  7. <script src="dist/js/jquery.jcalendar.js"></script>
  8.  
  9. <!-- CSV -->
  10. <script src="dist/js/jquery.csv.min.js"></script>
  11.  
  12. <!-- Formula -->
  13. <script src="dist/js/excel-formula.min.js"></script>

3.创建一个空的DIV元素,该元素将用作电子表格的容器。

  1. <div id="demo1"></div>

4.定义要在电子表格中显示的JS数据数组。

  1. data1 = [
  2. ['Google', 1998, 807.80],
  3. ['Apple', 1976, 116.52],
  4. ['Yahoo', 1994, 38.66],
  5. ];

5.初始化电子表格并完成。

  1. $('#demo1').jexcel({
  2. data:data1
  3. });

6.或者从外部JSON文件加载数据。

  1. $('#demo1').jexcel({
  2. url:'/json'
  3. });

7.如果您想将外部CSV文件加载到电子表格中。需要CSV扩展名。

  1. $('#demo1').jexcel({
  2. csv:'demo.csv',
  3. csvHeaders:true
  4. })

8.将电子表格数据导出为CSV文件:

  1. $('#demo1').jexcel('download');

9.自定义电子表格的默认插件设置:

  1. $('#demo1').jexcel({
  2.  
  3. // Column types and configurations
  4. columns:[],
  5.  
  6. // Column header titles
  7. colHeaders:[],
  8.  
  9. // Column width sizes
  10. colWidths:[],
  11.  
  12. // Column alignment
  13. colAlignments:[],
  14.  
  15. // Colum header classes
  16. colHeaderClasses:[],
  17.  
  18. // Column width that is used by default
  19. defaultColWidth:50,
  20.  
  21. // Minimal number of blank rows in the end
  22. minSpareRows:0,
  23.  
  24. // Minimal number of blank cols in the end
  25. minSpareCols:0,
  26.  
  27. // Minimal table dimensions
  28. minDimensions:[0,0],
  29.  
  30. // Custom context menu
  31. contextMenu:null,
  32.  
  33. // Allow column sorting
  34. columnSorting:true,
  35.  
  36. // Allow column resizing
  37. columnResize:true,
  38.  
  39. // Allow row dragging
  40. rowDrag:true,
  41.  
  42. // Allow table edition
  43. editable:true,
  44.  
  45. // Allow new rows
  46. allowInsertRow:true,
  47.  
  48. // Allow new rows
  49. allowManualInsertRow:true,
  50.  
  51. // Allow new columns
  52. allowInsertColumn:true,
  53.  
  54. // Allow new rows
  55. allowManualInsertColumn:true,
  56.  
  57. // Allow row delete
  58. allowDeleteRow:true,
  59.  
  60. // Allow column delete
  61. allowDeleteColumn:true,
  62.  
  63. // Allow cell commments
  64. allowComments:true,
  65.  
  66. // Global wrap
  67. wordWrap:false,
  68.  
  69. // Filename
  70. csvFileName:'jexcel',
  71.  
  72. // Disable corner selection
  73. selectionCopy:true,
  74.  
  75. // Allow Overflow
  76. tableOverflow:false,
  77.  
  78. // Allow Overflow
  79. tableHeight:200,
  80.  
  81. // Add custom Toolbar
  82. toolbar:null
  83.  
  84. });

10.API方法。

  1. // Get the full or partial table data
  2. // @Param boolan onlyHighlighedCells - Get only highlighted cells
  3. $('#demo1').jexcel('getData', false);
  4.  
  5. // Update the table data
  6. // @Param json newData - New json data, null will reload what is in memory.
  7. // @Param boolean ignoreSpare - ignore configuration of minimal spareColumn/spareRows
  8. $('#demo1').jexcel('setData', [json], false);
  9.  
  10. // Add a new column
  11. // @Param integer numberOfColumns - Number of columns should be added
  12. // @Param string headerTitle - Header title
  13. $('#demo1').jexcel('insertColumn', 1, { header:'Title' });
  14.  
  15. // Remove column by number
  16. // @Param integer columnNumber - Which column should be excluded starting on zero
  17. $('#demo1').jexcel('deleteColumn', 1);
  18.  
  19. // Add a new row
  20. $('#demo1').jexcel('insertRow', 1);
  21.  
  22. // Remove row by number
  23. // @Param integer rowNumber - Which row should be excluded starting on zero
  24. $('#demo1').jexcel('deleteRow', 1);
  25.  
  26. // Get the current header by column number
  27. // @Param integer columnNumber - Column number starting on zero
  28. $('#demo1').jexcel('getHeader', 2);
  29.  
  30. // Change header by column
  31. // @Param integer columnNumber - column number starting on zero
  32. // @Param string columnTitle - New header title
  33. $('#demo1').jexcel('setHeader', 1, 'Title');
  34.  
  35. // Get the current column width
  36. // @Param integer columnNumber - column number starting on zero
  37. $('#demo1').jexcel('getWidth', 2);
  38.  
  39. // Change column width
  40. // @Param integer columnNumber - column number starting on zero
  41. // @Param string newColumnWidth - New column width
  42. $('#demo1').jexcel('setWidth', 1, 100);
  43.  
  44. // Reorder a column asc or desc
  45. // @Param integer columnNumber - column number starting on zero
  46. // @Param smallint sortType - Zero will toggle current option, one for desc, two for asc
  47. $('#demo1').jexcel('orderBy', 2);
  48.  
  49. // Get current cell value
  50. // @Param mixed cellIdent - str compatible with excel, or as object.
  51. $('#demo1').jexcel('getValue', 'A1');
  52.  
  53. // Change the cell value
  54. // @Param mixed cellIdent - str compatible with excel, or as object.
  55. // @Param string Value - new value for the cell
  56. $('#demo1').jexcel('setValue', 'A1');
  57.  
  58. // Select cells
  59. // @Param object startCell - cell object
  60. // @Param object endCell - cell object
  61. // @Param boolean ignoreEvents - ignore onselection event
  62. $('#demo1').jexcel('updateSelection', [cell], [cell], true);
  63.  
  64. // Get the current data as a CSV file.
  65. $('#demo1').jexcel('download');
  66.  
  67. // Get the current value of one configuration by key
  68. // @Param string configuration key
  69. $('#demo1').jexcel('getConfig', 'allowInsertColumn');
  70.  
  71. // Set the value of one configuration by key
  72. // @Param string configuration key, @Param mixed configuration value
  73. $('#demo1').jexcel('setConfig', 'allowInsertColumn', true);
  74.  
  75. // Get table or cell style
  76. // @Param mixed - cell identification or null for the whole table.
  77. $('#demo1').jexcel('getStyle', 'A1');
  78.  
  79. // Set cell(s) CSS style
  80. // @Param mixed - json with whole table style information or just one cell identification. Ex. A1.
  81. // @param k [optional]- CSS key
  82. // @param v [optional]- CSS value
  83. $('#demo1').jexcel('setSyle', [ { A1:'background-color:red' }, { B1: 'color:red'} ]);
  84.  
  85. // Get cell comments
  86. // @Param mixed - cell identification or null for the whole table.
  87. $('#demo1').jexcel('getComments', 'A1');
  88.  
  89. // Set cell comments
  90. // @Param cell - cell identification
  91. // @Param text - comments
  92. $('#demo1').jexcel('setComments', 'A1', 'My cell comments!');
  93.  
  94. // Get the table or cell meta information
  95. // @Param mixed - cell identification or null for the whole table.
  96. $('#demo1').jexcel('getMeta', 'A1');
  97.  
  98. // Set the table or cell meta information
  99. // @Param mixed - json with whole table meta information.
  100. $('#demo1').jexcel('setMeta', [ A1: { info1:'test' }, { B1: { info2:'test2', info3:'test3'} } ]);

11.事件处理程序。

  1. $('#demo1').jexcel({
  2.  
  3. // on load
  4. onload: function(){},
  5.  
  6. // before a value is changed
  7. onbeforechange: function(){},
  8.  
  9. // after a value is changed
  10. onchange: function(){},
  11.  
  12. oncomments: null,
  13.  
  14. // after all change events are performed
  15. onafterchange: function(){},
  16.  
  17. // before a new row is inserted
  18. onbeforeinsertrow: null,
  19.  
  20. // after a new row is inserted
  21. oninsertrow: function(){},
  22.  
  23. // before a new column is inserter
  24. onbeforeinsertcolumn: function(){},
  25.  
  26. // after a new column is inserted
  27. oninsertcolumn: function(){},
  28.  
  29. // before a row is deleted
  30. onbeforedeleterow: null,
  31.  
  32. // after a row is deleted
  33. ondeleterow: function(){},
  34.  
  35. // before a column is deleted
  36. onbeforedeletecolumn: null,
  37.  
  38. // after a column is deleted
  39. ondeletecolumn: function(){},
  40.  
  41. // on selection
  42. onselection: function(){},
  43.  
  44. // after a column is sorted
  45. onsort: function(){},
  46.  
  47. // after a row is resized
  48. onresizerow: null,
  49.  
  50. // after a column is resized
  51. onresizecolumn:null,
  52.  
  53. // after a row is moved
  54. onmoverow: function(){},
  55.  
  56. // after a column is moved
  57. onmovecolumn: null,
  58.  
  59. // before paste
  60. onbeforepaste: null,
  61.  
  62. // after paster
  63. onpaste: null,
  64.  
  65. // after merge
  66. onmerge: null,
  67.  
  68. // on table focus
  69. onfocus: function(){},
  70.  
  71. // on table blur
  72. onblur: function(){},
  73.  
  74. // after a header is changed
  75. onchangeheader: null,
  76.  
  77. // after start editing
  78. oneditionstart: null,
  79.  
  80. // after end editing
  81. oneditionend: null,
  82.  
  83. // after styles are changed
  84. onchangestyle: null,
  85.  
  86. // after meta channged
  87. onchangemeta:null
  88.  
  89. });

更新日志:

版本4.11.3(2023-02-14)

  • 修复标题工具提示

版本4.11.1(2023-02-14)

  • 只读复选框/收音机。

版本4.10.1(2022-01-24)

  • 过滤更新,隐藏列+过滤,拖动列

版本4.9.11(2022-01-17)

  • reset筛选以刷新视口。

v4.9.9 (2021-12-28)

  • Transpile重构器

v4.9.6 (2021-10-21)

  • 日历修复-自动检测。

v4.7.4 (2021-05-05)

  • 使现代化

v4.6.0 (2021-02-15)

  • 重命名为J电子表格

v4.5.0 (2021-01-04)

  • 固定装置、过滤器等。

第4.4.2版(2020-10-28年)

  • 新事件oncomments,新方法getJsonRow。

版本4.4.1(2020-08-20)

  • 已更新

版本4.3(2020-06-27)

  • 过滤器中的新空白选项。

2020-06-17

  • 版本4.2.3

2020-05-26

  • 版本4.2.0

2020-04-28

  • 文档(v4)已更新

v4 (2020-04-21)

  • 支持工作簿/选项卡
  • 从HTML静态元素创建一个dymic-jexcel表
  • 在CTRL+C后高亮显示单元格中的边框
  • 支持配方奶粉的页脚
  • 多列调整大小
  • JSON更新支持(帮助更新远程服务器)
  • 全局超级事件(在一个事件中调度所有事件的集中式方法)
  • 自定义助手:=进度(进度条),=评级(五星评级)
  • 自定义帮助程序:=CUMN,=ROW,=CELL,=TABLE,=VALUE要在公式执行中使用的信息
  • 动态嵌套标头更新
  • 用于HTML编辑的新列类型
  • 新标志,如:includeHeadersOnCopy、persistence、filters、autoCasting、freezeColumns
  • 新事件,如:onevent、onchangepage、onbeforesave、onsave

2020-02-11

  • v3.9.0:插入行修复

2020-01-17

  • 版本3.8.0

2019-12-02

  • v3.6.3:错误修复

2019-11-15

  • v3.6.2:将文本解析为公式中的数字。

2019-09-27

  • v3.5.0:新事件、IE兼容性修复、常规修复和一些改进。

2019-08-21

  • v3.4.4:修复

2019-08-02

  • v3.3.3:修复,更好的npm支持以及jsuites。等

2019-07-09

  • 版本3.0.1
  • 文档已更新

2019-05-25

  • v2.1.0:移动触摸修复;粘贴修复程序和新建CSV解析器

2019-02-04

  • v2.0.2:修复了下载问题

2018-09-04

  • v1.5.7:细胞的Onmouseover事件

2018-07-01

  • 复制/剪切时的CSV双引号。赛前新活动

2018-06-20

  • v1.5.3/4:错误修复。

2018-05-18

  • v1.5.2:多个电子表格在同一页公式分离修复。

2018-05-02

  • v1.5.1:修复了具有表溢出和表高度的标头。小导航修复。

2017-12-07

  • formula Number()修复。

2017-09-11

  • 合并了新版本1.3.3。

2017-05-08

  • 版本上的箭头控件。

2017-05-04

  • JS更新。

2017-03-22

  • 新的上下文菜单和本地下拉筛选。

2017-03-14

  • 撤销重做以包含本机复选框

2017-03-05

  • 更新jquery.jexcel.css

2017-02-20

  • 使现代化

2017-02-11

  • 公式和箭头类似于导航改进。

2017-01-28

  • CSV包括第一行作为标题选项。下载CSV,包括

2017-01-26

  • 排序和排序。

2017-01-19

  • 允许动态添加列。

2017-01-14

  • 已实现撤消/重做功能

预览截图