我们已经有一个系统可以根据查询生成和呈现一些数据。对于用户来说,结果是一个可以在 Web 上看到的 HTML 表格。现在我们需要导出该数据,但由于组件结构,不可能创建一个变量来推送数据并将其导出为 xls 或 csv 格式。或者至少我们一直在这样挣扎并且没有结果。
你们中的一些人知道是否有可能读取呈现为 csv 或 xls 格式导出的 HTML 数据的函数或方法?
这是渲染代码的一部分。我们正在使用查询来获取数据并将其分配给不同的组件。
<div className="d-flex h-auto flex-column">
<Button type="primary" className="my-5 align-self-right" onClick={() => this.groupSum(allCodes, allCodesInit, allNits, allNitsInit, allCreditos, allDebitos, sumsInit)}>Generar</Button>
<div className="table-responsive" id="table-report">
<table className="table table-active mb-0">
<thead className="thead-light">
<tr>
{/* <td colSpan="2"></td> */}
<td colSpan="5" style={widthStyle} className="text-center">
<h1 className="text-uppercase d-block mb-0">{client}</h1>
<h5>NIT {nit}</h5>
</td>
{/* <td colSpan="2"></td> */}
</tr>
<tr>
<td><small><b>Reporte:</b></small></td>
<td className="no-top"><small>Balance de prueba</small></td>
<td style={widthStyle}></td>
<td><small><b>Fecha:</b></small></td>
<td className="no-top"><small>{new moment().format('L')}</small></td>
</tr>
<tr>
<td><small><b>Rango:</b></small></td>
<td><small>{monthInitial} - {monthFinal}</small></td>
<td style={widthStyle}></td>
<td><small><b>Página:</b></small></td>
<td><small>1/1</small></td>
</tr>
<tr>
<td colSpan="5" style={fullWidthStyle}></td>
</tr>
</thead>
</table>
<table className="table table-active">
<thead className="thead-light">
<tr className="text-center">
<th scope="col">Código</th>
<th scope="col" colSpan="1">Nombre</th>
<th scope="col">Saldo anterior</th>
<th scope="col">Débitos</th>
<th scope="col">Créditos</th>
<th scope="col">Nuevo saldo</th>
</tr>
</thead>
<tbody>
<FirstLvlCodes
deep={deep.toString()}
reportType={this.props.reportType}
thirdNits={[...this.props.thirdNits, ...this.props.suppliers].sort((a, b) => a.nit-b.nit)}
codes={this.state.codes}
codesInit={this.state.codesInit}
allCodes={this.state.allCodes}
allCodesInit={this.state.allCodesInit}
codesTree={this.state.codesTree}
nits={this.state.nits}
nitsInit={this.state.nitsInit}
firstLvlCodes={this.state.firstLvlCodes}
secondLvlCodes={this.state.secondLvlCodes}
thirdLvlCodes={this.state.thirdLvlCodes}
fourthLvlCodes={this.state.fourthLvlCodes}
fifthLvlCodes={this.state.fifthLvlCodes}
sixthLvlCodes={this.state.sixthLvlCodes}
debitos={this.state.debitos}
creditos={this.state.creditos}
sumsInit={this.state.sumsInit}
/>
</tbody>
</table>
</div>
</div>
我们感谢您的帮助!谢谢。