Get single value of merged cell after active cell
2 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/190543/image.png)
I have got this excel data and would like to access the value of merged cell. Some code I have worked with -
filename = '....\example.xls';
sheetname = 'Sheet15';
string = 'A15';
excel = actxserver('Excel.Application');
workbook = excel.Workbooks.Open(filename);
sheet = workbook.Worksheets.Item(sheetname);
find_string = sheet.Cells.Find(string,[],[],1)
string_row = find_string.Row; %ans here is 2
string_column = find_string.Column; %ans here is 8
required_stringrow = find_string.Row + 1; %ans here is 3
required_value = get(sheet, 'Cells', required_stringrow, string_column); %ans here is NaN
The value of the merged is present always in first cell(B3). So i can access it only from cell B2 with the above code. I get answer as NaN for cells C2,D2,E2,F2,G2,H2 for the above code. Instead I want answer as the value of merge cell. How do i do this??
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!