Exporting code from MATLAB and producing a table in Excel.
2 次查看(过去 30 天)
显示 更早的评论
I need to create a 3x2 arrangement of headers using the MATLAB function writetable. I need to replicate the picture below and include the same color code as well. I am having trouble doing so. The code is also attached below.
dataTable.Properties.RowNames % obtains the row names from the table
dataTable.Properties.VariableNames % obtains the variables
annotations.rowHeader % Obtains the Row Header from the table
annotations.columnHeader % Obtains the Column Header from the table
annotations.fileName % Obtains the File Name
%% Write to Excel Spreadsheet
writetable(dataTable,[annotations.fileName,'.xlsx']) % writes the table into an excel file
writetable(dataTable,[annotations.rowHeader,'xlsx']) % locates the row Headers from excel file
5 个评论
dpb
2020-6-26
What, precisely?
I recommended that if you wanted an Excel spreadsheet with a fancy set of colorings, etc., that aren't part of the builtin features of the high-level tools in MATLAB to write to Excel files, the expedient way to do so is to make those changes in Excel (you appear to already have one, so that shouldn't be hard) and save that sheet as a template spreadsheet.
Then, open/create a new workbook from that template when you need it and use writetable to write the data to it with the formatting already in place.
Look at the Excel help files or DAGS to learn how to use Excel...
Doing those changes in MATLAB will have to be done by using the COM engine; there aren't functions with those in ML -- ML lets you read/write data to/from Excel but it's not TMW's job to make every piece of Excel available.
回答(1 个)
Maadhav Akula
2020-7-1
Hi Wisam,
As @dpb pointed out there aren't direct functions/properties in Matlab that allow you to color code Excel cells, instead you have to utilise the COM Objects to do that.
You can have a look at the following posts which might help you out:
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!