none
How do I read records from Excel? RRS feed

  • General discussion

  • Guyz,
    I need this immediatelty. Please help.
    I used to retrieve records from Excel using the Micorosoft.Jet.OleDB Provider, library Excel 8.0 and IMEX = 1
    but the problem with that is the Data Types for the individual columns are lost, say the DataType for a Decimal column becomes String.
    I put these records in a DataTable from Excel and Bulk Insert in DB using SqlBulkCopy. But the issue is that the Columns in DB for that Bulk Insert table has its own data type, so if I try to insert the DataTable from Excel directly into the SqlBulkCopy I get an exception.
    Is there any way to preserve the DataType using Microsoft Excel InterOp?
    • Changed type liurong luo Friday, November 13, 2009 5:17 AM OP does not follow up.
    Friday, November 6, 2009 5:11 AM

All replies

  • Hi,
    have a look at this link
    http://support.microsoft.com/default.aspx/kb/302084
    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/b6e8a28c-6760-4e86-a1aa-e2ce9ec36380/
    Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
    Friday, November 6, 2009 5:22 AM
  • I am not exactly sure what you want to convey. I just need the data type to preserve when I import the records from Excel to DataTable. That means, if a column in excel is defined as decimal, that same column should appear as decimal in DataTable. Currently it is converted to String. Is there any way to preserve the DataType?
    Friday, November 6, 2009 6:05 AM
  • Hello,

    Would you please post your codesnippet here? What kind of exception did we meet?
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Monday, November 9, 2009 12:13 PM
  • Hello,

    We are changing the issue type to General Discussion because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to Question by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

    Thanks.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Friday, November 13, 2009 5:18 AM