Hi , can u help with a code to convert to get a data set
& convert the values in a table to .csv file which can be viewed in a Excel sheet
how to create an .csv (comma separated) file using an VB.net programming

ie

converting data in a table into csv (comma separated) file

the by getting a data set & converting the values in a table into a .csv file using an VB.net coding

sathya_k_83: Hi , can u help with a code to convert to get a data set 
& convert the values in a table to .csv file which can be viewed in a Excel sheet
how to create an .csv (comma separated) file using an VB.net programming

ie

converting data in a table into csv (comma separated) file

the by getting a data set & converting the values in a table into a .csv file using an VB.net coding

hii its very easy!!

EXPORT TO EXCEL:

private void btnExport2_Click(object sender, System.EventArgs e)
{
    // Export the details of specified columns
    try
    {
        // Get the datatable to export
        DataTable dtEmployee = ((DataSet) 
             Session["dsEmployee"]).Tables["Employee"].Copy();
        // Specify the column list to export
        int[] iColumns = {1,2,3,5,6};
        // Export the details of specified columns to Excel
        RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Web");
        objExport.ExportDetails(dtEmployee, 
             iColumns, Export.ExportFormat.Excel, "EmployeesInfo2.xls");
    }
    catch(Exception Ex)
    {
        lblError.Text = Ex.Message;
    }
}

EXPORT TO CSV

<PRE lang=cs id=pre1 style="MARGIN-TOP: 0px" nd="77">private void btnExportCSV_Click(object sender, System.EventArgs e)
{
    // Export the details of specified columns
    try
    {
        lblMessage.Text = "";

        // Get the datatable to export
        DataTable dtEmployee = dsEmployee.Tables["Employee"].Copy();
        // Specify the column list to export
        int[] iColumns = {1,2,3,5,6};
        // Export the details of specified columns to CSV
        RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win");
        objExport.ExportDetails(dtEmployee, 
             iColumns, Export.ExportFormat.CSV, "C:\\EmployeesInfo.csv");
        lblMessage.Text = "Successfully exported to C:\\EmployeesInfo.csv";
    }
    catch(Exception Ex)
    {
        lblMessage.Text = Ex.Message;
    }
}

refer this URL:
http://www.codeproject.com/aspnet/ExportClassLibrary.asp

regards,

Ammar.
:)

Edited 3 Years Ago by pyTony: fixed formatting

This article has been dead for over six months. Start a new discussion instead.