Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70817

Import and read excel file using ionic

$
0
0

0

i want to upload a excel file and read it using ionic-angular , i try with this code but it doesn’t work for ionic app its just work for browser i dont know why ?

i want to read it and get a value from it and it doesn’t work in ionic app (android )
if there is any plugin for excel file help me

this is my code

<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 suggestion help me

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70817

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>