VB.NET - VB.NET report generating options - Asked By Jason Tan on 12-Mar-07 09:23 PM


I currently developing an banking system, i need to retrive a .csv (comma seperated value) file and convert it to a datatable and generate a report. How do i generate a report beside using crystal report ? Any other technology options ?

Thank you. Its quite urgent

csv file to Excel XML spreadsheet - sundar k replied to Jason Tan on 13-Mar-07 02:02 AM

You can import the data from the csv file to Excel XML spreadsheet and thus you can have the report generated from the XMl spreadsheet.

You can download the source code written in VB.NET from


This sample application uses an XML header and footer.  It opens the comma separated file that the user chooses and then reads in line by line the contents of the file using a TextFieldParser. Then this app creates rows for each line and writes them to the output filesystem using a StreamWriter.


generate Word\Excel reports on the fly - mv ark replied to Jason Tan on 14-Mar-07 02:35 AM

Use this snippet to convert a CSV file to DataTable

using System.Data;
using System.Data.OleDb;
    string conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<replace folder path>;Extended Properties='text;HDR=No;FMT=Delimited'";

    string sql1 = "Select * From [test.csv]";

    DataTable dt1 = new DataTable("test.csv");
    OleDbDataAdapter da1 = new OleDbDataAdapter(sql1, conn);

There is method DataTable2ExcelString() at this link - http://authors.aspalliance.com/olson/methods/DataTable2ExcelString.aspx that takes a DataTable & converts its contents into a HTML table. This string containing the HTML table can be streamed as MIME content to Excel on the client as a downloadable report. Read more about this technique in my article "Download as Word/Excel" - http://eggheadcafe.com/tutorials/aspnet/6e1ae1a8-8285-4b2a-a89b-fafc7668a782/aspnet-download-as-wor.aspx

You can also choose to generate the report on the fly as a Word doc using the DataTable that you have generated from the CSV file. Check this code sample - http://www26.brinkster.com/mvark/dyna/downloadasdoc.html