Main Content

Change Row Height in Range of Spreadsheet Cells

This example shows how to change the height of a row, defined by a Range object, in a spreadsheet.

The Excel® Range object is a property that takes input arguments. MATLAB® treats such a property as a method. Use the methods function to get information about creating a Range object.

Create a Worksheet object ws.

e = actxserver('Excel.Application');
wb = Add(e.Workbooks);
e.Visible = 1;
ws = e.Activesheet;

Display the default height of all the rows in the worksheet.

ws.StandardHeight
ans =

    15

Display the function syntax for creating a Range object. Search the displayed list for the Range entry: handle Range(handle,Variant,Variant(Optional))

methods(ws,'-full')
Methods for class Interface.000208D8_0000_0000_C000_000000000046:

Activate(handle)
Calculate(handle)
handle ChartObjects(handle, Variant(Optional))
CheckSpelling(handle, Variant(Optional))
CircleInvalid(handle)
ClearArrows(handle)
ClearCircles(handle)
Copy(handle, Variant(Optional))
Delete(handle)
Variant Evaluate(handle, Variant)
ExportAsFixedFormat(handle, XlFixedFormatType, Variant(Optional))
Move(handle, Variant(Optional))
handle OLEObjects(handle, Variant(Optional))
Paste(handle, Variant(Optional))
PasteSpecial(handle, Variant(Optional))
handle PivotTableWizard(handle, Variant(Optional))
handle PivotTables(handle, Variant(Optional))
PrintOut(handle, Variant(Optional))
PrintPreview(handle, Variant(Optional))
Protect(handle, Variant(Optional))
handle Range(handle, Variant, Variant(Optional))
ResetAllPageBreaks(handle)
SaveAs(handle, ustring, Variant(Optional))
handle Scenarios(handle, Variant(Optional))
Select(handle, Variant(Optional))
SetBackgroundPicture(handle, ustring)
ShowAllData(handle)
ShowDataForm(handle)
Unprotect(handle, Variant(Optional))
handle XmlDataQuery(handle, ustring, Variant(Optional))
handle XmlMapQuery(handle, ustring, Variant(Optional))
addproperty(handle, string)
delete(handle, MATLAB array)
deleteproperty(handle, string)
MATLAB array events(handle, MATLAB array)
MATLAB array get(handle vector, MATLAB array, MATLAB array)
MATLAB array get(handle, MATLAB array, MATLAB array)
MATLAB array get(handle)
MATLAB array invoke(handle, string, MATLAB array)
MATLAB array invoke(handle)
MATLAB array loadobj(handle)
release(handle, MATLAB array)
MATLAB array saveobj(handle)
MATLAB array set(handle vector, MATLAB array, MATLAB array)
MATLAB array set(handle, MATLAB array, MATLAB array)
MATLAB array set(handle)

Create a Range object consisting of the first row.

wsRange = Range(ws,'A1');

Increase the row height.

wsRange.RowHeight = 25;

Open the worksheet, click in row 1, and notice the height.

Close the workbook without saving.

wb.Saved = 1;
Close(e.Workbook)

Close the application.

Quit(e)
delete(e)

See Also

Related Topics