MATLAB Answers

Exporting code from MATLAB and producing a table in Excel.

2 ビュー (過去 30 日間)
Wisam Aboubaker
Wisam Aboubaker 2020 年 6 月 25 日
回答済み: Maadhav Akula 2020 年 7 月 1 日
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 件のコメント

表示 2 件の古いコメント
dpb
dpb 2020 年 6 月 25 日
About?
Wisam Aboubaker
Wisam Aboubaker 2020 年 6 月 25 日
What you said.
dpb
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.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by