I have a HTML table that I want to copy to the clipboard.
However, I don't want the header row to be copied, only the rest of the table.
This is the table:
<table style="width:100%" #table>
<tr>
<th class="border"></th>
<th class="border"></th>
<th class="border"></th>
<th class="border"></th>
<th class="border"></th>
<th class="border"></th>
</tr>
<ng-template ngFor let-table [ngForOf]="mCase.Tables" let-i="index">
<ng-template ngFor let-row [ngForOf]="table.rows" let-rowIndex="index">
<tr>
<td>
....
</td>
</tr>
</ng-template>
</ng-template>
</table>
This is the Javascript I'm using to copy it:
@ViewChild('table') table: ElementRef;
var body = document.body as HTMLElement, range, sel;
if (document.createRange && window.getSelection) {
range = document.createRange();
sel = window.getSelection();
sel.removeAllRanges();
try {
range.selectNodeContents(this.table.nativeElement);
sel.addRange(range);
} catch (e) {
range.selectNode(this.table.nativeElement);
sel.addRange(range);
}
} else if (body.createTextRange) {
range = body.createTextRange();
range.moveToElementText(this.table.nativeElement);
range.select();
}
document.execCommand("Copy");
This code copies all of the table.
How do I copy the table without the header row?