Writing to table in matlab does not appear in a shared workbook?
2 views (last 30 days)
Show older comments
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
Accepted Answer
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
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
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... :(
More Answers (0)
See Also
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!