This article shares the specific code of Vue introducing the Excel table plug-in for your reference. The specific content is as follows 1. Installationnpm install handsontable-pro @handsontable-pro/vue npm install handsontable @handsontable/vue 2. Citation (Citation on the page)import { HotTable } from '@handsontable-pro/vue' import '…/…/node_modules/handsontable-pro/dist/handsontable.full.css' import Handsontable from 'handsontable-pro' 3. Use (use in labels)<div id="hotTable" class="hotTable"> <HotTable ref="hotTableComponent" :settings="hotSettings"></HotTable> </div> 4. Definition in Datadata () { return { list: [], root: 'test-hot', hotSettings: { data: [ // data can be a two-dimensional array or an array object], startRows: 3, // row and column range startCols: 3, minRows: 20, // Minimum number of rowsminCols: 5, // Minimum number of columnsmaxRows: 20, // Maximum number of rows and columnsmaxCols: 20, // Maximum number of columnsrowHeaders: true, // Row headers can be Boolean values (row numbers), strings (the left row headers display the same content, and can parse HTML), or arrays (the left row headers display content separately). colHeaders: ['Account Level', 'Account Name', 'Account Number', 'Account Category'], // Custom column header or Boolean valueminSpareCols: 0, // Column blankminSpareRows: 0, // Row blankcurrentRowClassName: 'currentRow', // Add a class name for the selected row, you can change the stylecurrentColClassName: 'currentCol', // Add a class name for the selected columnautoWrapRow: true, // Automatic line wrapclassName: 'htCenter htMiddle', // Default cell style, vertical centercontextMenu: { items: { // 'row_above': { // name: 'Insert a row above' // }, // 'row_below': { // name: 'Insert a row below' // }, // 'col_left': { // name: 'Insert column to the left' // }, // 'col_right': { // name: 'Insert column to the right' // }, 'hsep1': '---------', // Provide separator line 'remove_row': { name: 'Delete row' }, 'remove_col': { name: 'Delete column' }, 'make_read_only': { name: 'read-only' }, 'borders': { name: 'Table line' }, 'copy': { name: 'Copy' }, 'cut': { name: 'Cut' }, 'commentsAddEdit': { name: 'Add Notes' }, 'commentsRemove': { name: 'Cancel note' }, 'freeze_column': { name: 'Fixed columns' }, 'unfreeze_column': { name: 'Cancel column pinning' }, 'mergeCells': { name: 'Merge cells' }, 'alignment': { name: 'Text position' }, 'hsep2': '---------' } }, afterChange: function (changes, source) { // This method is triggered when the data changes // console.log(this.getSourceData()) this.list = this.getSourceData() // Get the data in the table // console.log(this.getPlugin('MergeCells').mergedCellsCollection.mergedCells) // Get the parameters of the merged cells in the table}, manualColumnFreeze: true, // Manually fix columns? manualColumnMove: true, // Manually move columnsmanualRowMove: true, // Manually move rowsmanualColumnResize: true, // Manually change column spacingmanualRowResize: true, // Manually change row spacingcomments: true, // Add comments? // cell: [ // ??? // {row: 1, col: 1, comment: {value: 'this is test'}} // ], customBorders: [], // Add borders columnSorting: true, // Sorting stretchH: 'all', // Expand horizontally according to width, last: only expand the last column, none: do not expand by default fillHandle: true, // Select and drag to copy possible values: true, false, "horizontal", "vertical" fixedColumnsLeft: 0, // Fixed the number of columns on the left fixedRowsTop: 0, // Fixed the number of columns on the top mergeCells: [ // Merge // {row: 1, col: 1, rowspan: 3, colspan: 3}, // Specify the merge, starting from (1,1), row 3 and column 3 are merged into one grid // {row: 3, col: 4, rowspan: 2, colspan: 2} ], columns: [ // Set the table header name { data: 'acctLevel' }, { data: 'acctName' }, { data: 'acctNo' }, { data: 'acctType' }, ] } } }, 5. Introducing componentscomponents: HotTable }, 6. Use of methodsmethods: { swapHotData: function () { // The Handsontable instance is stored under the `hotInstance` property of the wrapper component. // this.$refs.hotTableComponent.hotInstance.loadData([['new', 'data']]) console.log(this.$refs.hotTableComponent.hotInstance.getPlugin('MergeCells').mergedCellsCollection.mergedCells) } }, Key Points: this.$refs.hotTableComponent.hotInstance // Get table data, call table method, ****** points to the table getPlugin('MergeCells').mergedCellsCollection.mergedCells) // Get the parameters needed after merging cells Note: If you need to obtain data through the interface, just assign the data under this.hotSettings directly. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed explanation of the practice of installing the Permeate range system using VMware
>>: How to implement import and export mysql database commands under linux
Over a period of time, I found that many people d...
Let’s learn together 1. Traditional methods Copy ...
Table of contents Character Set Comparison Rules ...
The computer system has been reinstalled, and the...
How to modify the style of the el-select componen...
Achieve results Implementation Code html <div ...
Scenario: After installing the latest version of ...
1. High degree of collapse In the document flow, ...
I have installed various images under virtual mac...
Performance of union all in MySQL 5.6 Part 1:MySQ...
1: Install mongodb in docker Step 1: Install mong...
The enctype attribute of the FORM element specifie...
Table of contents 1. Data Source 2. Overall ranki...
There is no mysql by default in the yum source of...
In general applications, we use timestamp, dateti...