Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to Select Entire Row From Excel File Uisng Prompt?
Replies: 11   Last Post: Nov 23, 2012 5:52 PM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 ryanshuell@gmail.com Posts: 150 Registered: 2/11/08
How to Select Entire Row From Excel File Uisng Prompt?
Posted: Nov 17, 2012 7:18 PM
 Plain Text Reply

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');

Date Subject Author
11/17/12 ryanshuell@gmail.com
11/18/12 Phil Goddard
11/18/12 ryanshuell@gmail.com
11/18/12 Phil Goddard
11/19/12 ryanshuell@gmail.com
11/19/12 Phil Goddard
11/19/12 ryanshuell@gmail.com
11/20/12 Phil Goddard
11/20/12 Phil Goddard
11/20/12 ryanshuell@gmail.com
11/21/12 Phil Goddard
11/23/12 ryanshuell@gmail.com

© The Math Forum at NCTM 1994-2018. All Rights Reserved.