Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

problem with load of xlsx file


problem with load of xlsx file

Hi everyone, 

in my project I want to load information from an xls or xlsx file. 

My idea is to: 

1. load xlxs/xls file 

2. convert to json file 

3. use the json 


I tried to setup this piece of code, that is actually running for *.txt or *.json file: 

var xmlhttp = new XMLHttpRequest(); //apertura del file sequenze
xmlhttp.onreadystatechange = function() {
	if (this.readyState == 4 && this.status == 200) {
      	console.log(">> this: "+ this)
      	listaRicambi = JSON.parse(this.response)
        console.log(listaRicambi) // repair_sequence è il nome dell'oggetto indicato nel file .txt formattato con grammatica json
};"GET", "app/resources/Uploaded/" + fileName + ".xlsx", true);

So, when I inspect the preview mode console print some error like: 

Uncaught SyntaxError: Unexpected token P in JSON at position 0
    at JSON.parse (<anonymous>)
    at XMLHttpRequest.xmlhttp.onreadystatechange (app.js?v1611219048987:568)


Any idea?


Thank you so much. 


I think the approach as your tried is good, but I suspect it  will not work in this case.

If you mean xlsx file - is an EXCEL file - I do not think that we could parse this with the basic javaScript functionality e.g. JSON.parse(). So far I know this file is binary so that I do not know such parser could be used . Such parser should "understand" the excel functionality.(in generally could be possible)

What you can do : you can try to export your excel file to csv file and then try to convert the csv format – in case that this is some table values.

Also excel may be, could support some xml export format where you can find some existing xml parse to json.

Top Tags