Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
ryanshuell@gmail.com

Posts: 127
Registered: 2/11/08
How to Select Entire Row From Excel File Uisng Prompt?
Posted: Nov 17, 2012 7:18 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic 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');



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.