
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
react-to-excel
Advanced tools
a simple library to export React components and HTML tables to Excel files
react-to-excel
is a simple library that allows you to export React components and HTML tables to Excel files seamlessly. Built on top of exceljs
, this library provides an easy way to generate Excel spreadsheets directly from your React applications.
To install the package, use npm or yarn:
npm install react-to-excel
yarn add react-to-excel
const SampleTable: React.FC = () => {
const contentRef = useRef(null);
const handleExcelBtn = useReactToExcel({
documentTitle : "MyExcel",
sheetOptions :[{
contentRef : contentRef,
title :"Sample",
isRTL:false
}]
});
return (
<>
<button type={"button"} onClick={()=>handleExcelBtn()}>to .xlsx</button>
<div ref={contentRef} className="table" id={"content"}>
<table border={1}>
<thead>
<tr>
<th rowSpan={3}>Day</th>
<th colSpan={3}>Seminar</th>
</tr>
<tr >
<th colSpan={2}>Schedule</th>
<th rowSpan={2}>Topic</th>
</tr>
<tr>
<th>Begin</th>
<th>End</th>
</tr>
</thead>
<tbody>
<tr>
<td rowSpan={2}>Monday</td>
<td rowSpan={2}>8:00 a.m</td>
<td rowSpan={2}>5:00 p.m</td>
<td>Introduction to XML</td>
</tr>
<tr>
<td>Validity: DTD and Relax NG</td>
</tr>
<tr>
<td rowSpan={4}>Tuesday</td>
<td>8:00 a.m</td>
<td>11:00 a.m</td>
<td rowSpan={2}>XPath</td>
</tr>
<tr>
<td rowSpan={2}>11:00 a.m</td>
<td rowSpan={2}>2:00 p.m</td>
</tr>
<tr>
<td rowSpan={2}>XSL transformation</td>
</tr>
<tr>
<td>2:00 p.m</td>
<td>5:00 p.m</td>
</tr>
<tr>
<td>Wednesday</td>
<td>8:00 a.m</td>
<td>12:00 p.m</td>
<td>XLS Formatting Objects</td>
</tr>
</tbody>
</table>
</div>
</>
);
}
The useReactToExcel
hook accepts an options object with the following parameters:
Parameter | Type | Description |
---|---|---|
documentTitle | string | The title of the document to be generated. This will be the name of the Excel file when downloaded. |
sheetOptions | Array<SheetOption> | An array of objects that define the content and options for each sheet in the Excel file. Each object can contain: |
* contentRef : A reference to the React component or HTML element to be exported.* htmlContent : HTML content to be exported as a string.* title : The title of the sheet in the Excel file.* isRTL : A boolean indicating if the content is right-to-left (useful for languages like Persian or Arabic ..). | ||
author | string | The name of the author of the document. This can be included in the metadata of the Excel file. |
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
FAQs
a simple library to export React components and HTML tables to Excel files
The npm package react-to-excel receives a total of 9 weekly downloads. As such, react-to-excel popularity was classified as not popular.
We found that react-to-excel demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.