How can I format cell inputs when using writematrix?
Show older comments
I am currently using a program that generates Excel files after doing a few signal processing operations and taking user input (via a GUI).
The data I am outputting is essnetially tabular data based on what has been done. The GUI creates an Excel File based on user input and then writes data to a named sheet, which is also taken from user input. The general writing I currently use looks like this:
% Calculations and what not come first, and are then followed by this code which uses the results to write to Excel.
% Most of the inputs are determined by the user via the GUI, hence the odd variable names (avoids app.blahblahblah.Value everywhere)
% The Range positioning was determined manually to create a desired output appearance.
% This is the equivalent of the Main Title for the data set. I would like this bolded, bigger font, and center aligned.
writematrix(DataName1,filename,'Sheet',sheetname,'Range','A1')
% These are primary parameters to differentiate parts of the data. I would like these bolded, underlined, and color coded.
writematrix(Para1,filename,'Sheet',sheetname,'Range','B1')
writematrix(Para2,filename,'Sheet',sheetname,'Range','C1')
writematrix(Para3,filename,'Sheet',sheetname,'Range','D1')
% These are the names of which individual bits of data are being recorded. These would only be bolded.
writematrix(Record1,filename,'Sheet',sheetname,'Range','A2')
writematrix(Record2,filename,'Sheet',sheetname,'Range','A3')
writematrix(Record3,filename,'Sheet',sheetname,'Range','A4')
writematrix(Record4,filename,'Sheet',sheetname,'Range','A5')
% A few other iterations of writematrix that use variables which do not need to be formatted.
I am not sure what the best way to apply this kind of formatting is, and would really appreciate some help!
Accepted Answer
More Answers (1)
Walter Roberson
on 25 Oct 2020
0 votes
writematrix() cannot do any formatting; neither can writecell() or writetable().
To do formatting in .xls and .xlsx you need to be using MS Windows with Excel installed, and use ActiveX (or .NET) to talk to Excel to construct the formating instructions.
Categories
Find more on Spreadsheets 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!