0

ドキュメントでは、Excel シートから matlab にデータをプルする ためにdoc xlsread使用できることが説明されています。[num,txt,raw] = xlsread('example.xls')

他のシートにコピーする数式を含むシートがありますが、数式自体ではなくxlread、解釈された数式の値を取ります。たとえば、1 つの数式は=AVERAGE(B8:V8)プログラムでシートから取得0.810したいものですが、代わりに Excel は数式が返す値を返します。

matlabで何らかの方法で式を抽出することは可能ですか?

4

2 に答える 2

4

It is not possible with xlsread only.

One example of using a COM Excel object:

Let's use a simple excel sheet for example, containing text, values and formula :

excel snippet

Then the following code:

xlfile  = 'test1.xlsx' ;
xlRange = 'B3:C6' ;

exl = actxserver('excel.application');                  %// Create a COM server
exlFile    = exl.Workbooks.Open( [pwd '\' xlfile] );    %'// Open the file
exlSheet1  = exlFile.Sheets.Item('Sheet1');             %// Choose the worksheet
strFormula = exlSheet1.Range(xlRange).Formula           %// Read the full range

Yields a nice cell array :

strFormula = 
    'This is text'       'hello'          
    'this is value'      '12.5'           
    'this is value'      '29'             
    'this is formula'    '=AVERAGE(C4:C5)'

If you know directly the address of a specific cell, you return a simple string:

cellFormula = exlSheet1.Range('C6').Formula             %// Read a single cell

cellFormula =
=AVERAGE(C4:C5)
于 2015-08-05T20:04:47.530 に答える
1

を使用することはできませんxlsread。Excel ファイルの読み取りまたは Excel へのアクセスに使用できる API のいずれかを使用する必要があります。私の知る限り、選択肢は次のとおりです。

于 2015-08-05T19:36:38.383 に答える