Home » excel » Using xlswrite to export a large matrix from MATLAB to Excel

Using xlswrite to export a large matrix from MATLAB to Excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

I need to export a matrix which is much larger than the 1024 character limit. Is there a way around this limitation?

How to&Answers:

You have way more control interacting with Excel through COM instead of MATLAB’s built-in functions. Below is a small sample of what you can do. Perhaps it can help you write your array.

% Open a connection to Excel.
h = actxserver('Excel.Application');

% Make the Excel window visible.
set(h, 'Visible', 1);

% Create a new Excel workbook.
h.Workbooks.Add;

% Get the active Excel worksheet.
hSheet = h.ActiveSheet;

% Write to the cell at (A,1) on the active worksheet.
set(hSheet.Cells, 'Item', 1, 1, 123.456);

% Save and close the workbook.
h.ActiveWorkbook.Save;
h.ActiveWorkbook.Close;