I nead help, xlsread(file,-1).

9 visualizaciones (últimos 30 días)
Jola P
Jola P el 30 de Jul. de 2012
from doc:
[num,txt,raw] = xlsread(filename,-1) opens an Excel window to interactively select data. Select the worksheet, drag and drop the mouse over the desired range, and click OK.
How can I save this selected area (ex ‘A3:AB187’ or other) to use as a variable.I wont read in the same area (ex ‘A3:AB187’ or other) with multiple files.
Thanks,
Jola
  3 comentarios
nanren888
nanren888 el 1 de Ag. de 2012
Editada: nanren888 el 1 de Ag. de 2012
Maybe he means, can he find out the range that was selected as well as the contents.
Jola P
Jola P el 1 de Ag. de 2012
You're right nanren888. How can I save range that was selected, for example ‘A3:AB187’ or 'B17: D38' or other, from xlsread(FileName1,-1) to use as a variable. I wont read Data from this range (ex. ‘A3:AB187’ or other) with multiple files (FileName2, FileName3, ....FileName100).
Thanks.

Iniciar sesión para comentar.

Respuesta aceptada

Oleg Komarov
Oleg Komarov el 1 de Ag. de 2012
I'll rephrase the question to make it clear.
How can I return the address of the data which I selected interactively with:
xlsread(filename,-1)
After a bit of reverse engineering I found a semi-undocumented feature. It is possible to play with the COM object through the 5th input. The syntax I am gonna use is:
[num,txt,raw,custom] = xlsread(filename,sheet,range,'',functionHandle)
Step 1 Create the following function which will query the Address property
function [DataRange, range] = customOut(DataRange)
range = DataRange.Address;
end
Step 2 Now simply import the data with:
[num,txt,raw,address] = xlsread('test.xlsx',-1,[],[],@customOut)
address =
$B$7:$D$12
  1 comentario
Jola P
Jola P el 2 de Ag. de 2012
Thanks a lot! It works!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by