Date: Nov 17, 2012 7:18 PM
Author: ryanshuell@gmail.com
Subject: How to Select Entire Row From Excel File Uisng Prompt?

Hello Matlab experts.  I?m trying to figure out a way to enter a number/value into a prompt, and pass that value into Excel ColumnA, and read that entire used range into Matlab.  Here is the code that I?m working with (many lines are commented out as I was trying several ideas, but nothing worked). Basically, I want to enter a number/value, and have the entire row imported.  How can I do that?

[f, p] = uigetfile({'*.xls';'*.xlsx'},'Pick Excel File');
filename=fullfile(p,f);

% First, open an Excel Server.
e = actxserver('excel.application');

% Insert a new workbook.
eWorkbook = e.Workbooks.Add;
e.Visible = 1;

% Make the first sheet active.
eSheets = e.ActiveWorkbook.Sheets;

eSheet1 = eSheets.get('Item', 1);
eSheet1.Activate;

colEnd = sheetObj.Range(answer).End('xlToRight').Column
xlRange = xlRow + ':' + colEnd;
subsetA = xlsread(filename, sheet, xlRange)



%prompt={'Enter an Excel Row:'};
%title='Enter an Excel Row';
%answer=inputdlg(prompt,title);


%e = actxserver ('Excel.Application'); %# open Activex server
%ewb = e.Workbooks.Open(filename); %# open the file
%esh = ewb.ActiveSheet;

%excelObj = actxserver ('Excel.Application');
%excelWorkbook = excelObj.workbooks.Open(fileName);
%worksheets = excelObj.sheets;

%ewb = excelObj.Workbooks.Open(filename); %# open the file
%esh = worksheets.ActiveSheet;



%xlRow = answer;

% Row end, appears to work for rectangular data in sheet.
%rowEnd = sheetObj.Range('A1').End('xlDown').Row
% Column end for first row
%colEnd = sheetObj.Range('A1').End('xlToRight').Column



%excelObj = actxserver ('Excel.Application');

% Full path to your file required
%fileObj = excelObj.Workbooks.Open('c:\tmp\t.xlsx');

%sheetObj = excelObj.Worksheets.get('Item', 'Sheet1');

% Row end, appears to work for rectangular data in sheet.
%rowEnd = sheetObj.Range('A1').End('xlDown').Row
% Column end for first row
%colEnd = sheetObj.Range('A1').End('xlToRight').Column


%e = actxserver ('Excel.Application'); %# open Activex server
%filename = fullfile(pwd,'example2.xlsx'); %# full path required


%e = actxserver ('Excel.Application');
%filename = fullfile(pwd,'example2.xlsx');
%ewb = excelObj.Workbooks.Open(filename);
%esh = ewb.ActiveSheet;

%sheetObj = excelObj.Worksheets.get('Item', 'Sheet1');
%num_col = sheetObj.Range('A1').End(xlLeft).Column;

%intCol = Range('IV1').End(xlLeft).Col;

%excelObj = actxserver ('Excel.Application');
%filename = fullfile(pwd,'example2.xlsx');
%ewb = e.Workbooks.Open(filename);
%esh = ewb.ActiveSheet;

%sheetObj = e.Worksheets.get('Item', 'Sheet1');
%num_rows = sheetObj.Range('A1').End('xlDown').Row

%%sheet = 1;

%excelObj = actxserver ('Excel.Application');

% Full path to your file required
%fileObj = excelObj.Workbooks.Open(filename);
%num_col = sheetObj.Cells(sheetObj.Columns.Count, 1).End('xlLeft').Column
%sheetObj = excelObj.Worksheets.get('Item', 'Sheet1');