I need assistance in uploading an Excel file and reading it using Ionic-Angular. I tried the following code, but it only seems to work for browsers and not for the Ionic app on Android. Can someone please help me with this issue?
I am trying to read the Excel file and extract a value from it, but so far, it's not working on the Ionic app (Android). If there is any plugin or solution available for reading Excel files, I would greatly appreciate any help.
Here is the code snippet:
<ion-input #inputFile id="input-file" type="file" (change)="excelRead($event)" multiple></ion-input>
public excelRead(e :any ){
let fileReaded :any ;
fileReaded = e.target.files[0];
let type = e.target.files[0].name.split('.').pop();
console.log(fileReaded.name)
const schema = {
'Material' :{
prop : 'material',
type : String ,
required : false
} ,
'Description' :{
prop : 'description',
type : String ,
required : false
} ,
'Emplacement' :{
prop : 'emplacement',
type : String ,
required : false
} ,
'Physique' :{
prop : 'physique',
type : Number ,
required : false
} ,
'Sap' :{
prop : 'sap',
type : Number ,
required : false
} ,
'Ecart' :{
prop : 'ecart',
type : Number ,
required : false
} ,
'Cagette' :{
prop : 'cagette',
type : String ,
required : false
} ,
};
readXlsxFile(fileReaded, {schema}).then((data) =>{
console.log("message1")
if( data.rows){
for (let i of data.rows){
console.log("message2")
this.inventaireTab.push(i);
}
}
console.log("message3")
console.log(this.inventaireTab)
for (let i = 0; i < this.inventaireTab.length; i++) {
this.quantite.push(this.inventaireTab[i].physique)
}
console.log(this.quantite)
}
)
}
If you have any suggestions or solutions, please feel free to share them. Your help is greatly appreciated.