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

*No products are associated with this question.*

Answer by Fangjun Jiang
on 7 Oct 2011

Accepted answer

eActivesheetRange.NumberFormat='0.00'

Show 3 older comments

Fangjun Jiang
on 7 Oct 2011

Okay, maybe that's a MS Office version thing.

I never had experience plot to Excel via MATLAB.

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

Learn moreOpportunities for recent engineering grads.

Apply Today
## 3 Comments

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/17695#comment_39184

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

## George (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/17695#comment_39198

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

## Fangjun Jiang (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/17695#comment_39216

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