How to keep Excel format when using writematrix?

I am working on an app in AppDesigner and I want to export some data in an Excel file. This Excel file is already formatted and prepared for further export (e.g. PDF etc.). When I use the callback (button) in the app to export to Excel using the writematrix command, the data is stored correctly in my Excel sheet. However, Matlab overwrites the cell formatting, especially the column width. So now the Excel sheet is not useable for export and has to be changed again. Is there a way to store the data without altering the format of the cells and to keep the column width? Am I missing something in the writematrix command?

3 comentarios

Dyuman Joshi
Dyuman Joshi el 27 de Mzo. de 2024
What is the data-type of the data that you want to write?
If it is text data, fprintf would be a better fit for what you want to do.
Johannes
Johannes el 27 de Mzo. de 2024
The data is mostly numbers, some cells are text.
Dyuman Joshi
Dyuman Joshi el 27 de Mzo. de 2024
So, the data is text i.e. either string or char array(s)?
"Is there a way to store the data without altering the format of the cells and to keep the column width?"

Iniciar sesión para comentar.

Respuestas (1)

Johannes
Johannes el 27 de Mzo. de 2024
Movida: Dyuman Joshi el 27 de Mzo. de 2024

0 votos

The option 'AutoFitWidth',0 worked for me, thank you!

Productos

Versión

R2024a

Etiquetas

Preguntada:

el 27 de Mzo. de 2024

Movida:

el 27 de Mzo. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by