C
C#12mo ago
Shiv

❔ Multiple Read and write to an excel file simultaneously C#

Team, Can multiple users read an excel file ( say which is stored in network ) and update the values ..Similar to excel online... Will there be a lock ? Any one suggest or guide please
13 Replies
Ang619
Ang61912mo ago
I am no expert, but as far as i know when working with some "external" device (network adapter, USB, printer), then you need to work async. In your case you work with the network adapter, so you need to use async or your program will freeze. If multiple users exist, i also think you need threads or task on the network side, so it can handle multiple users
ZacharyPatten
ZacharyPatten12mo ago
we need more info on what exactly you are trying to do. simultaneous document editing is not a trivial feature. there is a lot that goes into it. are you meaning you want to make an app where mutliple users can edit the same file at the same time? I would not recommend that. How a lot of those apps that allow multiple users editing simultaneous is they have a database in the background and the data for the "file" is actually in a database rather than being an actual file like a standard .csv file. and the data has to be segmented in a way it can be easily updated independently. for example you can't require saving the entire file every time an update is made.
Shiv
Shiv12mo ago
OK got it ...thanks for the pointer.. Yes the idea is to make an app where mutliple users can edit the same excel file at the same time.. but got your suggestion of using DB instead of directly interacting with the file ... Was just curious how Excel online is implemented... Do you have any idea on its implementation?
Ang619
Ang61912mo ago
I dont know it fore sure but they definetly use Databases.
Luc ♡
Luc ♡12mo ago
your usecase indeed sounds fitting for a database. like most things that require any central data storage technology xd if your using something like sharepoint for example, multiple people should be able to edit it at the same time? I dont really remember, dont work with excel and word that much anymore.
Shiv
Shiv12mo ago
Yes will go with DB ...
Luc ♡
Luc ♡12mo ago
Honestly, depending on what your exact usecase is, having just a single api taking care of that one file handle would also do the trick
ZacharyPatten
ZacharyPatten12mo ago
Yes SharePoint allows multiple user edit. I just want to stress again though that this is not a trivial feature. There is a lot of nuance to it. Yes you will need a database, but you will need more than that. Permissions, proper data segmentation to allow efficient edits, data/communication to show everyone currently editing the same file, possibly edit history (change tracking), etc. etc. etc.
Luc ♡
Luc ♡12mo ago
but the users directly accessing the same file over e.g. smb is a bad idea and wont work like "expected" well said ZP
ZacharyPatten
ZacharyPatten12mo ago
not trying to discourage you. just trying to say the scope for this project is pretty large
Ang619
Ang61912mo ago
This sounds good
Shiv
Shiv12mo ago
Yes Understood @ZP ░▒▓█├■̶˾̶͞■┤█▓▒░ @lucheart going with db is the better option..Thanks for your inputs...
Accord
Accord12mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.