I want to merge cells A1 to E1... and give a heading with different colour and font... how to do it through matlab code....

1 Kommentar

king excel
king excel am 28 Okt. 2018
You can merge cells or rows or columns values easily using Dose for Excel Add-In: https://www.zbrainsoft.com/excel-merge.html

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

KL
KL am 27 Apr. 2017
Bearbeitet: KL am 27 Apr. 2017

5 Stimmen

Check here .
e = actxserver('Excel.Application');
% Add a workbook.
eWorkbook = e.Workbooks.Add;
e.Visible = 1;
% Make the first sheet active.
eSheets = e.ActiveWorkbook.Sheets;
eSheet1 = eSheets.get('Item',1);
eSheet1.Activate
% Merge Cells
eSheet1 = eSheet1.get('Range', 'A1:E1');
eSheet1.MergeCells = 1;
eSheet1.Value = 'text here';
eSheet1.Font.ColorIndex = 3
eSheet1.Font.Bold = 1;

5 Kommentare

KL
KL am 27 Apr. 2017
title? file name you mean?
Elysi Cochin
Elysi Cochin am 27 Apr. 2017
Bearbeitet: Elysi Cochin am 27 Apr. 2017
sir the code you gave is what i wanted...
but what if i want to write it in an excel named 'myexcel.xlsx' in 'sheet number 5',.... where to give it...
KL
KL am 27 Apr. 2017
then you have to change
eWorkbook = e.Workbooks.Add;
to
eWorkbook = e.Workbooks.Open(file);
where 'file' should be filename with fullpath. ('C:\file.xlsx')
Ricardo Gutierrez
Ricardo Gutierrez am 27 Jun. 2020
Very good. But, if I want to save the file from matlab, how should I do it?
梓斌
梓斌 am 2 Jan. 2025
thanks for your tip。
where 'file' should be filename with fullpath. ('C:\file.xlsx')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Gefragt:

am 27 Apr. 2017

Kommentiert:

am 2 Jan. 2025

Community Treasure Hunt

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

Start Hunting!

Translated by