How to display a spreadsheet/csv file in a website with react - reactjs

I am trying to display a spreadsheet or a CSV file on a website using react.js
The files are uploaded on the website and I just want to display the files inputted to the website. I have tried the popular meduim.com solution but it does not work for me, and it does not do exactly what I'm looking for.
I am not aware of the contents of the file which is uploaded to the website, but I just want to display whatever is uploaded to the website.

EDIT: If you want to parse xls file, you will 100% need a library. I've made a uploader that take excel before and parsing a xls file yourself is just a non starter. Look into this one.
There are many different library that you can use to do this but if you want to do this yourself, you can parse the csv into an array of array, then use map to create html element.
return (
<table>
csvArray.map(row => {
return <tr><td>row[0]</td></tr>
})
</table>
)

Related

How can I view a PDF using React?

How can I display the following binary array using React?
These are purely PDF files.
This could be successfully uploaded to an MSQL database.
On retrieval I get the shown string.
The file was not compressed ect.
"JVBERi0xLjcNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFuZyhkZS1ERSkgL1N0cnVjdFRyZWVSb290IDEwIDAgUi9NYXJrSW5mbzw8L01hcmtlZCB0cnVlPj4vTWV0YWRhdGEgMjIgMCBSL1ZpZXdlclByZWZlcmVuY2VzIDIzIDAgUj4+DQplbmRvYmoNCjIgMCBvYmoNCjw8L1R5cGUvUGFnZXMvQ291bnQgMS9LaWRzWyAzIDAgUl0gPj4NCmVuZG9iag0KMyAwIG9iag0KPDwvVHlwZS9QYWdlL1BhcmVudCAyIDAgUi9SZXNvdXJjZXM8PC9Gb250PDwvRjEgNSAwIFI+Pi9FeHRHU3RhdGU8PC9HUzcgNyAwIFIvR1M4IDggMCBSPj4vUHJvY1NldFsvUERGL1RleHQvSW1hZ2VCL0ltYWdlQy9JbWFnZUldID4+L01lZ...."

Display blob as doc file React

I am looking for a solution to display doc file in React app. I am using react-docx library to create a file I need and the documentation says we can do whatever we want with the binary file created. Anyway it shows only examples to save it on computer. What I wanna do is to make this blob tyle file display in a browser as doc. I wanted to use preview-docx library for that but it has very poor documentation and I am not sure if that would be a solution. Anyway there is another library like react-doc-viewer but it accepts only strings for document we want to display. Maybe anyone would know if it is even possible to display binary type files?
Packer.toBlob(doc).then((blob) => {
// instead of save as I want to display the file
saveAs(blob, "example.docx");
});

Download XLSX File from Salesforce with Data Validation

Can anyone confirm if there is the possibility of downloading xlsx file with Data Validation Logic from Salesforce? I know we can download the xls file as XML Spreadsheet but I would like to know if we can do it using the XLSX file.
It seems this is already discussed here.
Note: if you are doing this in VF or are able to execute Javascript, you can easily use something like sheetsJS to convert a json representation of your data to XLSX.

How to create PDF file and dowload in react js

I am working on react ja project which is contains pdf file download. I have list view which is contains some get service data from the api, exactly on the list view I have download button. If I click on the download button the list view should download as pdf file.
I have no idea how to that, so how to generate pdf file in react js?
There are two older answers for this in stackoverfow.
First one is this.
How to make PDF from React?
Second one is how to use jsPDF properly. And there is a working jsfiddle example allso. Refer them.
How to properly use jsPDF library

How to convert the uploaded file in Box.com?

https://salesforce.stackexchange.com/questions/45823/how-to-download-uploaded-file-in-box-com/46515#46515
In the above link the code will give an url (in the response) to download the file. But i want the file to be downloaded in HTML format. As per the box.com website i.e., https://developers.box.com/view/ they have given that we can convert the files to HTML. How can i do this using salesforce.
#Srilakshmi B S
If you want to download the file as HTML, you'll have to take the file and send it to the Box View service/API for conversion. The Box content API doesn't by itself allow you to convert documents for preview and download into HTML. That means that you'll need two separate tokens if using both API endpoint. If you are in fact planning to use both, there's some documentation here on how:
https://developers.box.com/using-the-view-api-with-the-content-api/

Resources