How can I automatically collapse grouped columns in a spreadsheet which is created using Excel's COM Automation Server?
The excel spreadsheet generated using the following code snippet:
excelObj = actxserver('Excel.Application');wb = excelObj.workbooks.Add;worksheets = excelObj.Sheets;for ii = 1 : worksheets.Count - 1 worksheets.Item(1).Delete;endsheetObject = wb.Sheets.Item(1);sheetObject.Range('A1:A2').Value = {'1';'2'};sheetObject.Range('A1:AX50').Value = num2cell(magic(50));sheetObject.Range('G:K').Columns.Group;wb.SaveAs([pwd,'\example.xlsx']);wb.Close(false);excelObj.Quit;delete(excelObj);
creates a group including the columns G, H, I, J, K but this group is shown as expanded when opening the generated excel spreadsheet.
Best Answer