Writing to table in matlab does not appear in a shared workbook?

2 views (last 30 days)
Trying to write to a excel workbook that has shared privileges. The shared workbook works when two seperate people open it and make changes. Where there is conflict a box appears that allows the users to accept the changes etc...
When i write on the same line using matlab, then use the write command to save it. The changes do not appear on the opened workbook when clicking save. It just saves whatever is in the current workbook at that time with 0 conflicts, even though matlab has already wrote to it.
You only see the changes when you close the workbook and open it again without hitting save.
Is there a way round this ?
  5 Comments
MKM
MKM on 13 Jan 2025
Cheers Stephen. After reading the documentation, sounds like that might be what i need with the write command. Fingers crossed!!
MKM
MKM on 16 Jan 2025
This does work, however the matlab app im working on would need to write often to the excel spreadsheet. This solution would results in multiple windows being opened of the same workbook. Not ideal. Cheers anyway!

Sign in to comment.

Accepted Answer

Naga
Naga on 16 Jan 2025
To manage real-time updates and conflicts in shared Excel workbooks when using MATLAB, use Excel's COM Automation server instead of simple file operations. This approach allows you to interact with Excel programmatically as if you were using it manually, reducing conflicts. Here's a concise example of using Excel's COM Automation server from MATLAB to manage shared workbooks:
% Example of using Excel COM Automation in MATLAB
excel = actxserver('Excel.Application');
workbook = excel.Workbooks.Open('path_to_your_shared_workbook.xlsx');
sheet = workbook.Sheets.Item('Sheet1');
% Make your changes
sheet.Range('A1').Value = 'New Value';
% Save the workbook
workbook.Save();
% Clean up
workbook.Close();
excel.Quit();
delete(excel);
  5 Comments
dpb
dpb on 16 Jan 2025
Edited: dpb on 17 Jan 2025
OK, I hadn't found that...I'll go poke around and hopefully find it...I just followed the directions when tried to share the working. Thanks for the tip...
Look at the FEX for sample Excel COM code -- there's a class of utility functions out there that is pretty useful but they've mucked up the user interface so badly that I can no longer find it...and, unfortunately, I inadvertently lost the contributor info while munging on the copy I downloaded and no longer remember whose it is...but it is one of the frequent contributors here.
I just went through about a dozenof those I remember well and none of them registered a hit, though...unless it has been removed for some reason which I'd not think likely.
dpb
dpb on 16 Jan 2025
"... you dont actually have to save it to the cloud."
Excepting I realize in this particular case I do because I need to share it with some folks who are not on the network... :(

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!