Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
Insert values from JavaScript to Python to file.xls

I'm trying to insert certain values into a xls or xlsx file, that have been fetched in JavaScript to the python function. How can I insert the values from the JavaScript function into the python function?

This is my python code:

import xlwt
from xlwt import Workbook

    @app.route('/Import_to_excel',
    methods=['GET', 'POST'])
    def Import_to_excel():
    
        x = request.args.get('id0')
        y = request.args.get('id1')
        z = request.args.get('id2')
    
        array = [ ip, app, ver]
        
        wb = Workbook()
        sheet1 = wb.add_sheet('Sheet 1')
    
        sheet1.write(0, 0, array[0])
        sheet1.write(0, 1, array[1])
        sheet1.write(0, 2, array[2])

        wb.save('xlwt example.xls')
        
        return "success"

I have also been trying to post a list with the values, instead of individually posting the values one by one. But i have some problems with request.args.getlist() on the Python side of things.

This is my JavaScript function

function Import_to_excel()
{
    id0 = document.getElementById("x").text
    id1 = document.getElementById("y").value
    id2 = document.getElementById("z").value

    const input_values = [ id0, id1, id2];

 fetch('http://127.0.0.1:5000/Import_to_excel?id0='+id0
 ).then(resp => resp.json())

 fetch('http://127.0.0.1:5000/Import_to_excel?id1='+id1
 ).then(resp => resp.json())

 fetch('http://127.0.0.1:5000/Import_to_excel?id2='+id2
 ).then(resp => resp.json())
}

The output in my xls file is blank.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Python code

id = request.args.get('ID')
x = id.split('_*_')[0]
y = id.split('_*_')[1]
z = id.split('_*_')[2]

JavaScript

  var x = document.getElementById("x").value;
  var y = document.getElementById("y").value;
  var z = document.getElementById("z").value;
  var a = 'http://127.0.0.1:5000/initiate_excel_corvert?ID='x+'_*_'+y+'_*_'+z+'_*_'
           fetch(a)
          .then(res => res.json())
          .then(res => console.log(res));
        }
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!