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!