react-data-export
react-data-export copied to clipboard
Excel Says 'Recover File' When Try to Create More Than One Sheets
My reason:
I am trying to create an Excel file with 2 Sheets containing different data. However, whenever I try to open the Excel file, Excel says I have to 'recover' the file before I can open it. After that, when it has opened the file, I notice that only one of the sheet is correct with the data I want. The other sheet is renamed as 'recovered_sheet' with the same data as the previous sheet, which is not what I want.
I then try to separate the two data into two different Excel file, each with the data I need. However, this time Excel is able to produce the file without any 'recover' error. It is only when I try to combine the data into one file (2 sheets) that the error occurs.
The Excel file generation is handled by React.js, in the render() part.
Steps to reproduce: Code as below.
Data = {
reportName: 'test',
reportType: 'test',
report: [
[{}, {}, {}, {}, {}, {},{}], //Object with 'property' matching 'col1', 'col2', 'col3', col4'
[{}, {}, {}] //Object with 'property' matching 'col5', 'col6'
],
column: [
['col1', 'col2', 'col3', 'col4'],
['col5', 'col6']
]
}
<ExcelFile
hideElement="true"
filename={this.props.Data.reportName}
>
<ExcelSheet
data={this.props.Data.report[0]}
name={this.props.Data.reportType}
>
<ExcelColumn key={this.props.Data.column[0][0]}
label={this.props.Data.column[0][0]}
value={this.props.Data.column[0][0]}/>
<ExcelColumn key={this.props.Data.column[0][1]}
label={this.props.Data.column[0][1]}
value={this.props.Data.column[0][1]}/>
<ExcelColumn key={this.props.Data.columnl[0][2]}
label={this.props.Data.column[0][2]}
value={this.props.Data.column[0][2]}/>
<ExcelColumn key={this.props.Data.column[0][3]}
label={this.props.Data.column[0][3]}
value={this.props.Data.column[0][3]}/>
</ExcelSheet>
<ExcelSheet
data={this.props.Data.report[1]}
name={this.props.Data.reportType}
>
<ExcelColumn key={this.props.Data.column[1][0]}
label={this.props.Data.column[1][0]}
value={this.props.Data.column[1][0]}/>
<ExcelColumn key={this.props.Data.column[1][1]}
label={this.props.Data.column[1][1]}
value={this.props.Data.column[1][1]}/>
</ExcelSheet>
</ExcelFile>
Lib Version: 0.4.2
@chuhean I see you are using same name for 2 different sheet, please try with unique names for each sheet
Thanks for your reply. Just wondering, is there a way to add bar chart into the excel sheet? I can't seem to find any relevant info from the docs so far.
@chuhean not yet with this library, but I'm adding all the macro support in upcoming excel API https://github.com/securedeveloper/javascript-excel
@securedeveloper No problem. Thanks a lot.