Disable Autofiltermode in excel sheet using matlab script

Hi Im trying to disable the filter applied in all the columns in excel sheet using below code but its not working. please help with right command to disalbe autofilter
[filename,path1]=uigetfile('*.xlsx','Select file');
filename1=strcat('\',filename);
filename=strcat(pwd,filename1);
exl = actxserver('excel.application');
exlWkbk = exl.Workbooks;
exlFile = exlWkbk.Open(filename);
exlFile.Activate
SignalDBsht=exlFile.Sheets.Item('Signal');
Activesheet.autofiltermode='False';
exlFile.Save();
exlFile.Close();
exl.Quit;
exl.delete;

回答 (1 件)

Jatin
Jatin 2024 年 9 月 6 日

0 投票

Your script to disable the "autofiltermode" is almost correct. The issue lies in assigning 'False' as a string instead of using a Boolean value.
Here's the revised code that should achieve the desired result:
% Activate the specific sheet
SignalDBsht = exlFile.Sheets.Item('Signal');
SignalDBsht.Activate;
% Check if AutoFilter is on and turn it off
if SignalDBsht.AutoFilterMode
SignalDBsht.AutoFilterMode = false;
end
Hope this helps!

カテゴリ

ヘルプ センター および File ExchangeData Import from MATLAB についてさらに検索

タグ

質問済み:

2020 年 4 月 10 日

回答済み:

2024 年 9 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by