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. Reading Excel from different processes in different computer

Reading Excel from different processes in different computer

Scheduled Pinned Locked Moved C#
helpcsharpquestion
4 Posts 4 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.
  • S Offline
    S Offline
    SaneLucky
    wrote on last edited by
    #1

    Hello, I've an application which reads and writes to a shared excel using C#. The application runs on different computers and whenever anybody writes to the excel a pop-up appears on all the computers in which the application is running and displays the recent message written to excel file. I am using FileSystemWatcher and an event is raised whenever something is written to the file. If this event occurs I am reading the excel file from each of the process and displaying the latest message. Now, when I am reading the excel file from different computers(processes) at the same time. All the processes does not get the latest message. I am opening the excel in readOnly and releasing the excel object successfully. Also, I have found that when many processes are trying to read from the same excel at the same time. The excel tends to crash. I have added a thread.sleep(3000) so that there is a delay in reading the excel file. This did help but still the excel throws error messages. Is there anyway that I can read excel file one after the other from each process?

    S A M 3 Replies Last reply
    0
    • S SaneLucky

      Hello, I've an application which reads and writes to a shared excel using C#. The application runs on different computers and whenever anybody writes to the excel a pop-up appears on all the computers in which the application is running and displays the recent message written to excel file. I am using FileSystemWatcher and an event is raised whenever something is written to the file. If this event occurs I am reading the excel file from each of the process and displaying the latest message. Now, when I am reading the excel file from different computers(processes) at the same time. All the processes does not get the latest message. I am opening the excel in readOnly and releasing the excel object successfully. Also, I have found that when many processes are trying to read from the same excel at the same time. The excel tends to crash. I have added a thread.sleep(3000) so that there is a delay in reading the excel file. This did help but still the excel throws error messages. Is there anyway that I can read excel file one after the other from each process?

      S Offline
      S Offline
      Super Lloyd
      wrote on last edited by
      #2

      what is the error message? or COM exception code? Is there any inner exception? These are valuable tips on what the problem could be!

      A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.

      1 Reply Last reply
      0
      • S SaneLucky

        Hello, I've an application which reads and writes to a shared excel using C#. The application runs on different computers and whenever anybody writes to the excel a pop-up appears on all the computers in which the application is running and displays the recent message written to excel file. I am using FileSystemWatcher and an event is raised whenever something is written to the file. If this event occurs I am reading the excel file from each of the process and displaying the latest message. Now, when I am reading the excel file from different computers(processes) at the same time. All the processes does not get the latest message. I am opening the excel in readOnly and releasing the excel object successfully. Also, I have found that when many processes are trying to read from the same excel at the same time. The excel tends to crash. I have added a thread.sleep(3000) so that there is a delay in reading the excel file. This did help but still the excel throws error messages. Is there anyway that I can read excel file one after the other from each process?

        A Offline
        A Offline
        April Fans
        wrote on last edited by
        #3

        Hello there, Please view the following: http://www.ehow.com/how_4451697_move-excel-macros-another-pc.html[^] http://stackoverflow.com/questions/9819236/call-vba-macro-from-different-computer-over-network[^] Hope this is useful to you. Best of Luck! With Kind Regards,

        April Comm100 - Leading Live Chat Software Provider

        1 Reply Last reply
        0
        • S SaneLucky

          Hello, I've an application which reads and writes to a shared excel using C#. The application runs on different computers and whenever anybody writes to the excel a pop-up appears on all the computers in which the application is running and displays the recent message written to excel file. I am using FileSystemWatcher and an event is raised whenever something is written to the file. If this event occurs I am reading the excel file from each of the process and displaying the latest message. Now, when I am reading the excel file from different computers(processes) at the same time. All the processes does not get the latest message. I am opening the excel in readOnly and releasing the excel object successfully. Also, I have found that when many processes are trying to read from the same excel at the same time. The excel tends to crash. I have added a thread.sleep(3000) so that there is a delay in reading the excel file. This did help but still the excel throws error messages. Is there anyway that I can read excel file one after the other from each process?

          M Offline
          M Offline
          micke andersson
          wrote on last edited by
          #4

          It sounds like you are taking every step possible to overcome some very common problems with network shares. The FileSystemWatcher and sleep(3000) may not be enough. Try creating a locked file (FileStream with Non-Sharing Mode) that your "listeners" try to access. Remove the lock once the message has been added and the excel file is written. But my guess is that you will never get rid of this problem. File access using network shares are never reliable when accessed from multiple computers simultaneously (in my experience).

          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