securedeveloper / react-data-export

Export dataset in react.
https://securedeveloper.github.io/react-data-export/
MIT License
179 stars 191 forks source link

[feature] Added nested object key access for data and column match #165

Open mehmetyilmaz001 opened 2 years ago

mehmetyilmaz001 commented 2 years ago

The following has been addressed in the PR:

Description:

[feature]

Accessing nested object is available with this PR

In the value prop of ExcelColumn, you can now provide nested object path like "user.name" as in the example

const dataSet = [
  {
     user: {name: 'Mehmet', surname: 'Yılmaz'},
     period: 'Eylül - Ekim'
  },

  {
     user: {name: 'Semih', surname: 'Yavuz'},
     period: 'Haziran - Temmuz'
  }
]

class Download extends React.Component {
    render() {
        return (
            <ExcelFile>
                <ExcelSheet data={dataSet} name="Employees">
                    <ExcelColumn label="Name" value="user.name"/>
                    <ExcelColumn label="Period" value="period"/>
                </ExcelSheet>
            </ExcelFile>
        );
    }
}