我希望能够以 Excel 文件格式导出我的 DOM 表格。
我的函数(Typescript 3.5 / Angular 8)
ExportTOExcel() {
const ws: XLSX.WorkSheet=XLSX.utils.table_to_sheet(document.getElementById('serversTable'));
const wb: XLSX.WorkBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Servers');
/* save to file */
XLSX.writeFile(wb, 'myproject.xls');
}
Run Code Online (Sandbox Code Playgroud)
我的桌子:
<table id="serversTable" mat-table [dataSource]="serverArray" multiTemplateDataRows>
<ng-container matColumnDef="number">
<th mat-header-cell *matHeaderCellDef>Qty</th>
<td mat-cell *matCellDef="let resourceGroup">
...
</td>
</ng-container>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>name</th>
<td mat-cell *matCellDef="let resourceGroup">
...
</td>
</ng-container>
<!-- Other columns -->
<ng-container matColumnDef="expandedDetail">
...
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let resourceGroup; columns: displayedColumns;" class="example-
element-row" …
Run Code Online (Sandbox Code Playgroud) 我正在使用 .md 文件在 Material for Angular 的对话框中显示信息。问题是markdown文件中的表格,当它们在DOM中显示时,没有边框。所以我尝试添加一些css。
::ng-deep table {
border-collapse: collapse;
border-spacing: 0;
border:2px solid black;
}
::ng-deep th {
border:2px solid black;
}
::ng-deep td {
border:1px solid black;
}
Run Code Online (Sandbox Code Playgroud)
如果不添加::ng-deep
,则我的桌子上不会应用任何样式,因此我不得不使用它。它工作正常,我的表格现在有边框,但它会影响我的其他组件,如何解决?
编辑:这是我的模板:
<div markdown [src]="data"></div>
我的函数用于更新属性:
updateUserInfo(user, attributes) {
Auth.updateUserAttributes(user, attributes)
.then(
result => {
console.log(result); // SUCCESS
}
)
.catch(
error => {
console.log(error);
}
);
}
Run Code Online (Sandbox Code Playgroud)
结果是SUCCESS
,在我的 AWS Cognito 服务中,在特定用户的页面上,我可以看到属性已更改。所以更新在 Cognito 中运行良好。
但是,当我在调用此更新函数后刷新角度应用程序的页面时,旧属性仍然存在,而不是新属性。所以我认为需要刷新当前用户会话变量才能获取新属性,该怎么做?
注意:我不明白的是,在显示用户属性的角度应用程序的页面上,我向亚马逊发出 GET 请求以获取用户属性。因此,如果在获取这些信息之前已完成更新,为什么我仍然获得旧属性?