I've been researching ways to manipulate data written to EXCEL spreadsheets using MATLAB. I came across the following example code and began manipulating individual lines of code & observing the outcome.
%%Clear out the environement
clear all;close all;clc;%%OPEN EXCEL APPLICATION
Excel = actxserver('Excel.Application');% Show the Excel window
set(Excel, 'Visible', 1);%%INSERT NEW WORKBOOK
W = Excel.Workbooks.Add;%%WORKBOOKS CONTAIN WORKSHEETS
Sheets = Excel.ActiveWorkBook.Sheets;Sheets.Add( [], Sheets.Item(3) ); %%ADD DATA AND CHARTS
j=2;%%Rename
Sheets.Item(j).Name = ['s' int2str(j)];%%Make it "Active"
Sheets.Item(j).Activate;Activesheet = Excel.Activesheet;Activesheet.Columns.Item('A').NumberFormat='$#,##0.00'; Activesheet.Columns.Item('A').ColumnWidth='20'; Activesheet.Range('A1').EntireColumn.HorizontalAlignment = 3; Activesheet.Range('A1').EntireColumn.VerticalAlignment = 2; %%Insert (random) data
A = floor(256*rand(10,1));ActivesheetRange = get(Activesheet,'Range','A1:A10');set(ActivesheetRange, 'Value', A);
One thing I can't seem to figure out is how to manipulate a single cell within a column of data. For example, I would like to align the contents in cell A1 to the left, leaving all other cells as-is.
Can this be done?
Best Answer