2017-10-23 3 views
0

複数のワークシートを持つExcelエクスポートを実装しようとしています。私は剣道のページ自体で解決策(例)を得ることができませんでした。 APIのドキュメントでは、ワークブックのオプションにアクセスすることができました。Kendo UI for Angular 2:複数のワークシートを持つExcelエクスポート

2枚以上のシートを持つExcelを作成するにはどうすればよいですか?

は現在、私は剣道ページから簡単な例を使用して、それをしようとしている: https://www.telerik.com/kendo-angular-ui/components/excelexport/

答えて

0

剣道デモで提供された例を使用して、各シートのためExcelExportComponentインスタンスを作成し、単一のファイルとしてでそれらをマージすることができます(Plunkerのコードを参照):

import { Component } from '@angular/core'; 
import { products } from './products'; 

@Component({ 
    selector: 'my-app', 
    template: ` 
     <button type="button" class="k-button" (click)="doExcelExport([excelexport1,excelexport2])">Export To Excel</button> 

     <kendo-excelexport [data]="data" fileName="Prod1.xlsx" #excelexport1> 
      <kendo-excelexport-column field="ProductID" title="Product ID"> 
      </kendo-excelexport-column> 
      <kendo-excelexport-column field="ProductName" title="Product Name"> 
      </kendo-excelexport-column> 
     </kendo-excelexport> 
     <kendo-excelexport [data]="data" fileName="Prod2.xlsx" #excelexport2> 
      <kendo-excelexport-column field="ProductID" title="Product ID"> 
      </kendo-excelexport-column> 
      <kendo-excelexport-column field="ProductName" title="Product Name"> 
      </kendo-excelexport-column> 
     </kendo-excelexport> 
    ` 
}) 
export class AppComponent { 
    public data: any[] = products; 

    public doExcelExport(components: ExcelExportComponent[]): void { 

     var options = components[0].workbookOptions(); 
     if (components.length > 1){ 
      for (var x = 1; x < components.length; x++) { 
       options.sheets[x] = components[x].workbookOptions().sheets[0]; 
      } 
     } 
     components[0].save(options); 
    } 
} 
関連する問題