我有一个 Angular 材料项目,我正在尝试使用该模块将数据从表中导出到xlsx
文件中。MatTableExporter
我有列ID
,Name
和actions
(编辑和删除),但它只显示列 ID 和操作,名称列显示为空。
我的问题:因为名称列显示为空,我怎样才能显示数据?如何从xlsx
文件中删除操作列?
这是我的component.html
:
<div class="title">Customers</div>
<mat-divider></mat-divider>
<div fxLayout="column" fxLayoutGap="10px" class="m-3">
<mat-card class="mat-elevation-z8">
<div>
<button mat-raised-button
(click)="exporter.exportTable('xlsx')">Export excel
</button>
</div>
<mat-table matTableExporter [dataSource]="clients" #exporter="matTableExporter">
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef>ID</mat-header-cell>
<mat-cell *matCellDef="let clients"> {{clients.id}} </mat-cell>
</ng-container>
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
<mat-cell *matCellDef="let clients; let i = index">
<mat-form-field floatLabel="never" [appearance]="editIndex != i ? 'none' : 'legacy'">
<input matInput placeholder="{{clients.name}}" [(ngModel)]="clients.name" [readonly]="editIndex!=i">
</mat-form-field>
</mat-cell>
</ng-container>
</ng-container>
<ng-container matColumnDef="act">
<mat-header-cell *matHeaderCellDef> Actions </mat-header-cell>
<mat-cell *matCellDef="let element
<button mat-icon-button matTooltip="Edit" (click)="edit(element)">
<mat-icon class="icon_edit_button">edit</mat-icon>
</button>
<button *ngIf="editIndex != i" mat-icon-button matTooltip="Delete" (click)="delete(element)">
<mat-icon>delete_forever</mat-icon>
</button>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let col; columns: displayedColumns;"></mat-row>
</mat-table>
<mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons></mat-paginator>
</mat-card>
</div>
这是我的xlsx
文件: