I'm using FileSaver library on my React application to export data to CSV, the data have characters with accent and when i open it with Excel it doesn't show properly (like this: é) however it shows properly when i open it with another text editor like VS Code
Here's the code i use :
FileSaver.saveAs(new Blob([csv], {type: "text/plain;charset=utf-8"}),"id_physique_"+ this.props.secuFoncierExportName+".csv");
FileSaver.saveAs(new Blob([csv_legal], {type: "text/plain;charset=utf-8"}),"id_morale_"+ this.props.secuFoncierExportName+".csv");
Does anyone have a solution for this issue ?
Thanks in advance
I had a similar problem with this library trying to export CSV files which afterwards are imported to Microsoft Excel.
file-saver exports the data in UTF-8 encoding. It seems like Microsoft Excel doesn't use the correct encoding while reading the file via File -> Open.
If you import the file in Microsoft Excel via the provided import functionality, you can specify the encoding. You can find the functionality via the menu (Data -> From Text/CSV).
Related
Would like to ask for some help I am currently using Tabulator (4.9) along with Vue. I am having trouble downloading/exporting my data to Excel. I have already included SheetJS on my project as stated from Tabulator's page.
The following gives me an error that the XLSX is not defined:
import 'xlsx/dist/xlsx.full.min.js'
this.tabulator.download('xlsx', 'data.xlsx')
But once I include the XLSX, then it tells me "Download Error - No such download type found":
import XLSX from 'xlsx/dist/xlsx.full.min.js'
this.tabulator.download(XLSX, 'data.xlsx')
Would really like to know if I am missing something.
Thanks.
Your first approach is correct, you should be calling the download function and passing in the xlsx string
this.tabulator.download('xlsx', 'data.xlsx');
The issue is that Tabulator is expecting to find the XLSX object on the window object (or global object if this is a node project) as that is where the library is put when pulled in from the CDN.
So in you case your import should be:
import XLSX from 'xlsx/dist/xlsx.full.min.js';
window.XLSX = XLSX;
I haven't tried using tabulator. You could look over its documentation again to see if you are missing something. Otherwise, I have used vue-json-csv. You can import it globally and call it anywhere you want to in your templates.
<DownloadCsv :data="exportData" name="export.csv">
<button class="mr-2">Export to csv</button>
</DownloadCsv>
It takes a data prop, which would be the json data set you wish to export to excel. And the name prop, this is going to be the name of the export file when it is generated.
I'm using NodeJS to do an app that finds and replaces a text in a pdf. I have found some approaches:
Using some npm package, like pdfReader, that converts pdf to json. So I get the text and replaces it with what I want. The problem it's convert the output back to pdf.
The possible solution for the first item it's to convert the PDF to HTML, edit the HTML and convert it back to pdf. But most of the tutorials using NodeJS it's about convert HTML to PDF, not PDF to HTML.
Any solutions for this problem?
Update
I ended up using PDFKit to create the pdf files that i need. In my case, this solution don't to cover all the possibles. But if you have to find a word and replace it in an unpredictable pdf file, maybe this problem has no solution in nodeJS. The PDFKit lib has an open issue for this feature.
Look at this approach how to export json data to pdf file with specify format with Nodejs?. Basically uses your idea. Convert PDF to JSON and then render the JSON in html, then convert the HTML to pdf.
We are currently Exporting to Excel from ui-grid custom menus. The xls Excel file is generated from JavaScript (in the UI); however, we need to support the xlsx format. Problem is when we change the extension to xlsx, opening the file in Excel 2013is generates an error.
Here's a JavaScript code snippet show how we save the xls file:
var blob = new Blob([html], { type: 'data:application/vnd.ms-excel;base64,' });
saveAs(blob, "exported.xls");
Can we accomplish export to xlsx from JavaScript, without relying on some third party package?
I'm looking into Open XML file formats on msdn but it appears to be server-side oriented; that is, generating xlsx files from c#.
Here's an example generating from c# - https://msdn.microsoft.com/en-us/library/office/gg278309.aspx
I apologize if the question is too generic, as I'm struggling to find a proper solution.
regards
Javascript running where? If you mean in your browser then the short answer is no - the security model does not allow Javascript to create files.
But presumably the data is getting onto your page where javascript can read it from somewhere - so just generate the file there.
I have a plunker attached herewith.
http://plnkr.co/edit/RkUCchxd6UghOTclMDFj?p=preview
I am able to import a text file properly without any errors. However, when I try to import an Excel file, it imports random alphanumeric values and unrelated data.
Can you please let me know if there is an easy way out there to import and Excel file (csv and xlsx file )?
I read online and found this document but I am not sure how it is used in JavaScript and HTML. Can anyone help?
http://psjinx.com/programming/2014/01/04/parsing-excel-workbooks-using-javascript/
<html>
You may use js-xlsx library to parse excel file to json using javascript
js-xlsx
the readme file explain how to use the library, or you may refer to the following article which talks about the library usage
Parse and Read Excel Files (xls/xlsx) With JavaScript
How can we export the contents of the jQuery Datatables to proper Excel format? The current implementation only exports to .csv file. Does any one have a demo or working example for this?
More details are the discussion here and here.
If you want to export in excel only format you have to modified the "TableTools.min.js" file.
You have to open "TableTools.min.js" file and replace ".csv" with ".xls" word. Then it will work export proper Excel format.
Also if you want download updated "TableTools.min.js" download by below link.
https://drive.google.com/file/d/0B8IHTmhRUyLpcjhnWWpOR3k3dlE/edit?usp=sharing
Thanks & Regards
Deepak Joshi
9899835174