Creating CVS file text format - javascript

I am creating a CSV file using JavaScript. I was unable to manage text format(like header text should be bold). Please help me if anyone has any idea around my requirement.

As far as I know, it is not possible to include text formats in a CSV file. If you want to include formatting information with the data for display in Excel (or am application compatible to some extent with Excel) an alternative may be to produce an XLSX file instead. There are libraries available to do this in Javascript. See, for example, https://github.com/SheetJS/js-xlsx
EDIT: I have just noticed that the freely available community edition of js-xlsx apparently does not support formatting. An alternative is the following library: https://www.npmjs.com/package/exceljs

Related

How to detect the file type if it's an excel file in JavaScript on the web?

I am using the FileReader() API to read files on the browser, I want to render something on the screen conditionally based on the file the user uploads:
JSON.
CSV.
Excel.
How can I detect if the file uploaded is an excel file? Do you use libraries for that or is there a genius way we can detect that blindly without going through all the chances?
Running out of space in comments, so I'll add an answer. Files will usually have an extension, on both Windows and Linux, but if you don't want to rely on that you can just try parsing the file in each of the formats to find the one that succeeds.
JSON use JSON.parse()
Excel see this question for .xlsx or this one for .xls, or use one of the many NPM packages
CSV the format is pretty simple, but there are gotchas for commas in the values. Some of the libraries are pretty efficient at streaming large files, so probably worth using an NPM package again

Export HTML Table to MS Excel 2010

I am trying to get my html table in a MS Excel document and I have tried many examples from here and internet but most of them didn't work. Mostly I can download a .xls file and when excel opens that file it comes nothing (not even standard Excel grid). And when I open the .xls files with Notepad, I can see that file actually holds values.
Most of the comments in previous questions were telling they work but these question dates are also little bit old and I can't tell if I am having version problems.
For example Javascript to export html table to Excel , I can download an Excel file but can't see values in it.
Also this DataTables example work well for me but I don't need all the stuff they provide like searching and listing.
Please let me know if any of you had such trouble and how did you solve them.
You have a solution (by your own admission): DataTables. Any features you don't need can be turned off or just not used.

Reading XLS/XLSX Data With JavaScript in NetSuite

I'm looking into potentially building code for NetSuite to read the contents of an Excel file (XLS or XLSX) within JavaScript in order to process the data. I can do this just fine with a CSV file, but I'd like to expand capabilities to read Excel worksheets.
I've seen a variety of scripts to read in Excel files, but they all seem to revolve around a dependency of Internet Explorer, and none of them seem to offer a solution on how to get the used columns and rows. They assume you already know this information ahead of time. NetSuite being what it is, these solutions don't really work, and you have to grab the base64 encoded contents of the file object stored in the system. This isn't an issue with CSV files, it's still just plain text.
I've done some testing and found that I get different results when trying to decode the string (I get something from XLS, but nothing from XLSX). I was wondering if anyone has tried and succeeded and reading data from these files formats in a NetSuite JavaScript implementation. If there's no good way, then I'll just have to force use of CSV, but I'd like to have some flexibility.
Essentially, you are asking for a javascript implementation of XLS and XLSX parsers. It is incredibly difficult, mostly due to the nature of the data format and the sheer amount of parsing required to get basic data).
I have built a basic version:
http://oss.sheetjs.com/js-xls/ (xls)
http://oss.sheetjs.com/js-xlsx/ (xlsx)

Exporting data to excel using javascript under following constraint

I have a project on exporting data to excel using JavaScript. But the constraints are : It should work for all browsers unlike ActiveXObject(that works only for Internet Explorer), window.open(that doesn't works for internet explorer).
It should not depend on other applications like Flash (I have seen a code using jQuery and Flash, but I can't use that in my project) e.t.c.
Please tell me whether it is possible and if it is, then suggest me a method to do this...
And one more thing, Manual work shouldn't be there or if it is, then it should be very less. In other words, it should be completely automated.
Suggestions:
use CSV file format and write a CSV writer in JavaScript yourself
use Microsoft's Office Open XML file format (xlsx) and write JavaScript code that generates such a file (should not be too difficult as it is XML based and there should be a lot of code around generating XML in JavaScript)

Generating Excel Spreadsheets - old format

I figured out how to generate Excel spreadsheets that open with newer versions of Excel, but it turns out many clients are using old versions of Excel. So I need to figure out how to generate old Excel files.
I used this to generate the files:
http://en.wikipedia.org/wiki/Microsoft_Excel#XML_Spreadsheet
I don't need anything too complex, I just need to insert simple rows and columns. I can't find anything that shows me the old format though (I'm hoping it's at least something human-readable). I'm not even entirely sure which versions of Excel they are using. Is there some way I can generate an Excel document that will work for older versions?
I'd prefer if there was something that let me generate the file myself, but a library would be fine too. I'm using JS and Node, and all I can find is node-excel, which claims to have the first version done in March, and I assume will have the same problem as the simple program I wrote (not working with versions of Excel prior to 2002).
Thanks for reading.

Categories