Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Change Excel Number Format From Matlab

Asked by George on 7 Oct 2011

Hi

How to change excel number format to 2 decimal places from matlab using actxserver?

For example:

e = actxserver('Excel.Application');
eWorkbook = e.Workbooks.Add;
e.Visible = 1;
eSheets = e.ActiveWorkbook.Sheets;
eSheet1 = eSheets.get('Item', 1);
eSheet1.Activate;
eActivesheetRange = e.Activesheet.get('Range', 'A1');
eActivesheetRange.Value = 0.022432;
eActivesheetRange.NumberFormat = ????

I want excel to displa 0.02

Thanks

George

3 Comments

Jan Simon on 7 Oct 2011

Please use proper code formatting, as explained in the "Markup help" link.

George on 7 Oct 2011

Sorry but i don't know how to use proper code formating

Fangjun Jiang on 7 Oct 2011

When you post your question, look at the {}Code button above the text box.

George

Products

No products are associated with this question.

1 Answer

Answer by Fangjun Jiang on 7 Oct 2011
Accepted answer

eActivesheetRange.NumberFormat='0.00'

6 Comments

George on 7 Oct 2011

I must put '0,00'.
Do you know how to plot to excel via matlab?
Thanks

Fangjun Jiang on 7 Oct 2011

Okay, maybe that's a MS Office version thing.
I never had experience plot to Excel via MATLAB.

George on 7 Oct 2011

It's fine. thank you very much

Fangjun Jiang

Contact us