justreact-advanced
Version:
It is combo of loading elements
82 lines (54 loc) • 2.25 kB
Markdown
`justreact-advanced` is an npm package designed to facilitate the downloading and saving of various types of files including CSV, ZIP, images, Excel, and PDF files. It provides a straightforward and efficient way to handle file downloads in React applications.
- **Download**: Download CSV files by passing an encoded string.
- **ZipSave**: Save files in a ZIP format.
- **ImageSave**: Save images.
- **StrToByte**: Convert strings to byte arrays.
- **Excel**: Save and download Excel files.
- **PDF**: Save and download PDF files.
To install the package, run:
```bash
npm install justreact-advanced
yarn add justreact-advanced
```
```js
import { fileSave } from "justreact-advanced";
// Example CSV data encoded as a string
const csvData = "data:text/csv;charset=utf-8,Name,Age\nJohn,30\nJane,25";
fileSave((type = "csv"), csvData, "example.csv");
```
type:"csv"| "excel" | "pdf" | "zip" | "image"
Download(encodedString, fileName)
encodedString (string): The encoded string to download.
fileName (string): The name of the file to save.
ZipSave(files, fileName)
files (Array): An array of objects with name and content properties.
fileName (string): The name of the ZIP file to save.
ImageSave(imageUrl, fileName)
imageUrl (string): The URL of the image to save.
fileName (string): The name of the image file to save.
StrToByte(str)
str (string): The string to convert to a byte array.
Excel(data, fileName)
data (Array): The data to include in the Excel file.
fileName (string): The name of the Excel file to save.
PDF(content, fileName)
content (string): The HTML content to include in the PDF file.
fileName (string): The name of the PDF file to save.
License
This project is licensed under the MIT License.
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Special thanks to the contributors and the open-source community for their support.
For any questions or feedback, please reach out at kumararvindra7691@gmail.com.