Showing posts with the label CVS

My Firefox Bug with Returning Csv Content

So this was an interesting bug that I encountered last week and it was just happening with Firefox. I'm not complete sure about the information I found but my guess was firefox  grabs it's file types from the register in windows. Either way my issue was what I was using for the mime type and below is what I tried in order.

application/  - This would for some users open up the file in xls and trim file name.
application/csv - Worked fine for all my users.
text/csv - Worked just like the previous one. I think this is the safest choice. I'm already treating it like a text file on the server side so this would more apparent in my case to use.

How do I map a .csv MIME type to the "Microsoft Excel Comma Separated Values File" application?
What to set as mimetype for csv files to open in spreadsheet applications - Stack Overflow

MVC Data Exported to Excel with NPOI

This is an article for just writing an Excel file using NPOI and I want the quickest and easiest way to export a excel file from MVC. To keep everything in work fluid motion I will keep the user on the same page and do a forced download within that page. This is a setup that I have seen in multiple times and I think works great in today's modern website designs.

Creates excel files
Leniel Macaferi's blog: Creating Excel spreadsheets .XLS and .XLSX in C#
Create Excel Spreadsheets Using NPOI
var workbook = new HSSFWorkbook(); var ExampleSheet = workbook.CreateSheet("Example Sheet"); var rowIndex = 0; var row = ExampleSheet.CreateRow(rowIndex); row.CreateCell(0).SetCellValue("Example in first cell(0,0)"); rowIndex++; Problems I faced XLS is not the same as CVS which is obvious but truthfully I did not know the difference between the two file types (other than their different extensions). So I asked myself what is the Difference between CSV and XLS files? W…