none
Can I concurrently read different worksheets in one workbook? RRS feed

  • Question

  • I'm using Microsoft Excel Object Model to read contents in Excel files.

    Each Excel file (workbook) can contain several worksheets. I'm wandering whether and how can I concurrently read different worksheets in this workbook with multi-threading. I've tried to make one thread own one WorkSheet instance. However this approach kept throwing exception: "

    Unhandled Exception: System.Runtime.InteropServices.COMException: Exception from
     HRESULT: 0x800401A8

    "

    So, is concurrent reading possible?

    Thursday, July 9, 2015 12:02 PM

All replies

  • Hi WangWangXi,

    As far as I know, the Office Object Model is not thread-safe, they don't guarantee there're no concurrency problems when use multi-threads to manipulate the worksheets.

    Please firstly take a look at this documentation:

    Multithreading and Memory Management

    The answer in this thread should give you a clearer suggestion:

    Can I update an excel workbook from multiple threads?

    My suggestion is not to manipulate the Office OM concurrently since there're no clear documentation or declaration of which part of the Office OM is thread-safe. Use some other store mechanism to store and process the data.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, July 13, 2015 3:38 AM
    Moderator