Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. XLS import [modified]

XLS import [modified]

Scheduled Pinned Locked Moved C#
comxml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ElCachubrey
    wrote on last edited by
    #1

    Hi all How i can read xls file with out using standard COM library of Excel(Microsoft Excel x.0 Object Library), because it work very slow. I try to export data from XLS file to XML file first and after read this XML file, but unfotunately Excel 9.0 library has not this functionality. Any idea please. -- modified at 9:22 Thursday 29th November, 2007

    K 1 Reply Last reply
    0
    • E ElCachubrey

      Hi all How i can read xls file with out using standard COM library of Excel(Microsoft Excel x.0 Object Library), because it work very slow. I try to export data from XLS file to XML file first and after read this XML file, but unfotunately Excel 9.0 library has not this functionality. Any idea please. -- modified at 9:22 Thursday 29th November, 2007

      K Offline
      K Offline
      KennyPatel
      wrote on last edited by
      #2

      Dear Friend, Hi. ;P string strFileName = "fileName.xls"; System.Data.OleDb.OleDbConnection excelConn = new System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source= '" + strFileName + "'; " + " extended properties=excel 8.0;"); string strsql = "Select * from [Sheet1$]"; System.Data.OleDb.OleDbDataAdapter excelDataAdap = new System.Data.OleDb.OleDbDataAdapter(strsql, excelConn); dsExcel = new DataSet(); if (excelConn.State == ConnectionState.Closed) { excelConn.Open(); } //Select the values from Excel excelDataAdap.Fill(dsExcel); GridView1.DataSource = dsExcel; GridView1.DataBind(); System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(strsql, excelConn); System.Data.OleDb.OleDbDataReader dr = cmd.ExecuteReader(); string sqlConnectionString = "Data Source=srvr;Initial Catalog=db;User Id=usr;Password=pwd"; // Bulk Copy to SQL Server System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(sqlConnectionString); bulkCopy.DestinationTableName = "ExcelData"; bulkCopy.WriteToServer(dr); I hope this will helps u.....

      "Good Thing Goes With Good People..."

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups