apache / cordova

Apache Cordova
https://cordova.apache.org/
623 stars 64 forks source link

probelm in downloading .xlsx file from Angular + Cordova android app #188

Closed ParthMDave closed 4 years ago

ParthMDave commented 4 years ago

Apache Cordova uses GitHub Issues as a feature request and bug tracker only. For usage and support questions, please check out the resources below. Thanks!


You can get answers to your usage and support questions about Apache Cordova on:


I am working in angular 8 project. I have one component which process some data & export this data to excel using XLSX.WorkSheet method. When i run my application in browser then it successfully download EXCEL file(.xlsx).

Now i am converting my angular 8 application to Cordova android, all functionality working same as brower view of my angular app but when i tring to Export EXCEL then file not downloading.

Here i show some code of angular project for Export Excel data as below

import { ExportAsService, ExportAsConfig, SupportedExtensions } from 'ngx-export-as';
import * as XLSX from 'xlsx';
constructor(private exportAsService: ExportAsService) {}

public exportExcel(jsonData: any[], fileName: string): void {
    const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(jsonData);
    const wb: XLSX.WorkBook = { Sheets: { 'data': ws }, SheetNames: ['data'] };
    const excelBuffer: any = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
    var out = XLSX.write(wb, { type: 'base64' });
    var xlsContent = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + out;
    this.exportAsService.downloadFromDataURL(fileName, xlsContent);    
}

I am working in angular 8 project. I have one component which process some data & export this data to excel using XLSX.WorkSheet method. When i run my application in browser then it successfully download EXCEL file(.xlsx).

Now i am converting my angular 8 application to Cordova android, all functionality working same as brower view of my angular app but when i try to Export EXCEL then file not downloading.

Here i show some code of angular project for Export Excel data as below.

import { ExportAsService, ExportAsConfig, SupportedExtensions } from 'ngx-export-as'; import * as XLSX from 'xlsx'; constructor(private exportAsService: ExportAsService) {}

public exportExcel(jsonData: any[], fileName: string): void { const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(jsonData); const wb: XLSX.WorkBook = { Sheets: { 'data': ws }, SheetNames: ['data'] }; const excelBuffer: any = XLSX.write(wb, { bookType: 'xlsx', type: 'array' }); var out = XLSX.write(wb, { type: 'base64' }); var xlsContent = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + out; this.exportAsService.downloadFromDataURL(fileName, xlsContent);
} Using above code i am able to download excel file when click on Excel button in Angular 8 Application in browser. i want same behavior in Android .APK(Cordova). i am not aware more about cordova, is any effort require to download file in Cordova app?

timbru31 commented 4 years ago

I'm closing this issue and re-quote what the template said:

Apache Cordova uses GitHub Issues as a feature request and bug tracker only. For usage and support questions, please check out the resources below. Thanks!


You can get answers to your usage and support questions about Apache Cordova on: