xlsread merge & center and highlight in red

1 view (last 30 days)
Ender
Ender on 12 Aug 2014
Answered: Ilyas on 20 Oct 2014
I am writing an xlswrite file and I want to write a header before I imput my date. I want to know if I can write a command to Merge & Center text in a specific line of the file. For example, I want to write a file that merges 'Title' from A1 to I1. Can I do this in MATLAB?
I would also like to write in the excel file an array that is written in red font. How do I do this? I wasn't sure what to ask the help search results to learn how to do this myself.
--Ender--

Answers (2)

Iain
Iain on 13 Aug 2014
Ok, theres three things you have to do:
1. Determine the visual basic code that excel uses to achieve that. Record a macro or whatever to get the code.
2. View the matlab code for xlsread & xlswrite to learn a bit about how matlab uses visual basic commands to control excel via activeX.
3. Put the two together.

Ilyas
Ilyas on 20 Oct 2014
True = 1;
False = 0;
xlCenter = -4108;
excelOutputFileName = 'full path\excelfile.xlsx'
Excel = actxserver('Excel.Application');
Excel.Visible = 0; % to see the excel file real time make 1;
Workbook = Excel.Workbooks.Open(excelOutputFileName);
Range = Excel.Range('A1:I1');
Range.Select;
Range.MergeCells = True;
Range.HorizontalAlignment = xlCenter;

Tags

Community Treasure Hunt

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

Start Hunting!