Display contents of CSV file in table with MVC - asp.net-mvc

My requirement is simple. I need a button that'll open a csv file and display the contents in a table of rows/columns. What's the best way to do that in MVC?

Use the built in CSV parser in .NET to parse the CSV file into an array, then use that array as the model for your view and render the table with a simple foreach loop.

Related

How to loop through a web table column and download multiple PDF files using Automation Anywhere?

I have an HTML table that has seven columns and 3 rows (the number of rows may be more or less). The second columns contains a links to PDF files and the seventh column contains the phrase "Corrective Action" I only want to download the PDF files from the columns that contain the word "Corrective Action". However, my code is only downloading the first PDF.
Here is the code:
http://dev.atriumfinehomes.com/clonewebtable/sample.PNG
This is the table:
http://dev.atriumfinehomes.com/clonewebtable/table.htm
Could I get some help with this please?
Get the links of the PDF files using Extract Table command.
Steps to get the links:
- Edit the Extract Table command -> Advanced view -> Step 6: Extract Selected Tag details to CSV file. Tag Name: Hyperlink, Attribute Name: Get URL.
- Save the data to another CSV file. (You can't save it in the same file as it will append or overwrite).
- Open the file CSV file as a spreadsheet.
Inside the loop
- Create a new variable $vCounter$, because the links.csv file dosn't conation headers as the table.
- Using variable operation assign $Counter$-1 to $vCounter$.
- Using Get Cells command and get cell A$vCounter$ and assign it to a new variable $vPDFURL$.
- Use $vPDFURL$ as Download file URL in the download command.
It's because you only download the 'correctiveaction1.pdf' but the PDF from the line 3 is named 'correctiveaction3.pdf'

Writing List of object into CSV File in xamarin.Android

Can any one suggest me How to implement writing List of objects into .csv into device download storage in c# xamarin android.The data exported to csv should be having headers.each item in list should be written in row .something similar to image attached
To create a CSV string, you'd generally do this manually. As an example:
string headers = $"{Column1},{Column2}";
string row1 = $"{row1.ValueA},{row1.ValueB}";
...etc...
Then append them together, separated by newlines. Obviously you'd be better off doing the above in some kind of loop.
As for putting it into android download storage, someone else will have to tell you how to do that, I don't know how!
i have followed below link http://www.joe-stevens.com/2009/08/03/generate-a-csv-from-a-generic-list-of-objects-using-reflection-and-extension-methods/ that helped me to implement.

Programmatically generated CSV file format issue for Excel and Numbers

In my iOS project, I have programmatically generated csv file from my data. Most of time, it looks all good for Microsoft Excel and Apple Numbers to open with.
But when the cell data is something like 5 - 60, it seems Excel would automatically convert it to date value like May-60, while Numbers open it correctly.
I have found this thread: https://stackoverflow.com/a/165052/833885, so the solution makes Excel happy is using "=""5 - 60""". But this will make Numbers shows ="5 - 60"......
You can quickly generate empty csv file to test what I described above.
Is is possible to generate csv file that makes all world happy???
Thanks in advance.
You can create a new file in excel and import from the data ribbon tab - this gives options to specify the data types for 'columns' in the csv. A bit of a pain but will avoid the issue.

Excel to pdf conversion in rails4 with libreoffice

In a rails 4 application, how can I convert an excel spreadsheet file into pdf.
When I am trying to implement Excel to pdf the contents are listed in different pages if excel column size is large.
How to generate the pdf without moving data to next pages in pdf.
Please help,
Thanks
So you basically have two options you can either implement this yourself and use a CSV gem/library (default CSV, faster CSV, or smarter CSV) assuming that by "excel" a CSV is acceptable. If a CSV is not acceptible you can use the axlsx gem instead. Then for pdf conversion you can use something like prawn. If you decide to build this yourself follow these steps.
Create a controller that will handle Reports, I suggest using the rails g controller report upload generate_table show generate_pdf generator to create a controller and a view for the upload process
Create a file upload form in the upload view.
On submit you will send the file to the generate action processing with one of the CSV or excel gems
Once processed your end product should be an array or hash (as an instance variable) and you can send that to the show action
In the show view you will iterate of that hash/array and incapsulate the contents in a html table.
On the show view you should have a button that will send that same hash/array to the generate_pdf controller action where you will use prawn to create a pdf, you can use something like send_data to the send the completed pdf file back to the user.
This is roughly how you could go about it less the low level details. Now if you wanted to use an out of the box solution you could use something like Ruport. Ruport will handle most of the heavy lifting for you the only thing is you need to have your models and associations set up to use it the way it is designed, and that may not be an option for you.

Create object in Rails from text file

I am building a site with Ruby on Rails where I can display items that are for sale. Currently I can add new items by filling a form with title, price, some text and upload a couple of pictures.
Since there might be many items I would like to have a text file with the data, one item on each line, data separated with comma or whatever. Then I'd like to give this file to my Rail's application that will create the items in the application. Would this be possible?
What you're basically talking about is importing and exporting CSV files.
You can learn about the basic ruby functions available to you when working with CSV files here: http://ruby-doc.org/stdlib-2.3.0/libdoc/csv/rdoc/CSV.html
Here's a video about exporting to csv and here's a video about importing from csv.
You essentially will call :to_csv on some collection, and then use CSV's foreach or some method of iterating the items in the CSV, and you will create your rows from the parsed data.

Resources