我正在尝试通过单击按钮将整个数据从当前网格复制到剪贴板,因此可以将其粘贴到任何目的地(excel、记事本等)
我尝试使用 wijmo.Clipboard 类,但对我没有用。
import * as wjcCore from 'wijmo/wijmo';
@ViewChild('grid') grid: GridComponent;
copysGrid() {
let hdr = '';
for (let c = 1; c < this.grid.columns.length; c++) {
hdr += '\t';
hdr += this.grid.columns[c].header;
}
let cellRange = new CellRange(-1, -1, -1, -1);
this.grid.select(cellRange);
cellRange = new CellRange(1, 1, this.grid.rows.length - 1, this.grid.columns.length - 1);
const gridData = this.grid.getClipString(cellRange);
const a = hdr + '\r\n' + gridData;
// wjcCore.Clipboard.copy(a);
const selBox = document.createElement('textarea');
selBox.style.position = 'fixed';
selBox.style.left = '0';
selBox.style.top = '0';
selBox.style.opacity = '0';
selBox.value = a;
document.body.appendChild(selBox);
selBox.focus();
selBox.select();
document.execCommand('copy');
document.body.removeChild(selBox);
}
任何人都可以帮助我如何做到这一点。