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

295
Views
How to format cells in excelsheet for export to excel in ReactJs

I am new at this, tried to find ways to do it,but was not able to.

I am performing export to excel on a click of Export button and data to be saved in .csv file or .xlsx file format.

I want the data to be saved in below way:

enter image description here

But somehow I dont know how to do it in ReactJs.

I have tried something like this :

this.state = {
            headers: [
                { key: 'srNo', label: 'srNo' },
                { key: 'student', label: 'student'}, 
                { key: 'student.firstname', label: 'firstname'},
                { key: 'student.lastname', label: 'lastname'},
                { key: 'student.age', label: 'age'},
            ]
        };

<Button>

                                <Button 
                                    style={{ float: "right", margin: "5px" }}
                                    variant="contained"
                                    color="primary"
                                    onClick={this.ExportToExcel}
                                    data={this.props.student.records}
                                    headers={this.state.headers}
                                    filename={"test.csv"}
                                    // filename={"menu.csv"}
                                    className="btn btn"
                                    target="_blank"
                                    >
                                        Export
                                    </Button>

I get all the proper data from the database. I just want it to get exported in a particular way in excel file as shown in the image above. Also see how the rows and columns are merged with center as formatting and the font being bold. I want my data to get export in the exact same way as in the image above.

I need to do proper formatting of the excel file in headers or so.

I don't know how to go about it. Need help.

about 4 years ago · Juan Pablo Isaza
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!