You must Sign In to post a response.
  • Category: .NET

    Taking more time to open

    HI..
    In my one of application am getting lot excel files so i need to open and read the data.

    For open exel am using below code
    Excell.Application excelApp = new Excell.Application();

    But sometime it takes more time to pass this line.
    IS there any way to speedup the process...
  • #769225
    HI,

    In that Object you have many data's, try to split up the data something like this,

    in Excell obj you have 5 excels, So make it like

    Excel1 - 1 Sheet
    Excel2 - 1 sheet
    .
    .
    Excel5- 1 Sheet

    So that you know the process in which sheet and you can make it easier.

    Thanks,
    Mani

  • #769247
    you can also read Excel Data using ole db Connection
    using below code

    public DataTable ReadExcel(string fileName, string fileExt) {
    string conn = string.Empty;
    DataTable dtexcel = new DataTable();
    if (fileExt.CompareTo(".xls") == 0)
    conn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties='Excel 8.0;HRD=Yes;IMEX=1';"; //for below excel 2007
    else
    conn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties='Excel 12.0;HDR=NO';"; //for above excel 2007
    using(OleDbConnection con = new OleDbConnection(conn)) {
    try {
    OleDbDataAdapter oleAdpt = new OleDbDataAdapter("select * from [Sheet1$]", con); //here we read data from sheet1
    oleAdpt.Fill(dtexcel); //fill excel data into dataTable
    } catch {}
    }
    return dtexcel;
    }


Sign In to post your comments