react-excel-renderer icon indicating copy to clipboard operation
react-excel-renderer copied to clipboard

4th column name missing

Open nhammad opened this issue 3 years ago • 1 comments

I am trying to use this:

        <OutTable data={rows ? rows : []} columns={cols ? cols : []} tableClassName="ExcelTable2007" tableHeaderRowClass="heading" />

to read a file that has 4 column. It shows me my col names/letters till D including the index but for my last column, it doesn't show the column title or a letter at the top. Can this be fixed?

nhammad avatar Jun 21 '21 16:06 nhammad

A workaround is to add an empty column:

renderFile = (fileObj) => {
    //just pass the fileObj as parameter
    ExcelRenderer(fileObj, (err, resp) => {

        const columns = [{name: '', key: 0}];
        resp.cols.map(item => {
            columns.push({name: item.name, key: item.key + 1});
            return null;
        })

        if (err) {
            console.log(err);
        } else {
            this.setState({
                dataLoaded: true,
                cols: columns,
                rows: resp.rows
            });
        }
    });
}

YakimchykNadzeya avatar Nov 18 '21 08:11 YakimchykNadzeya