From: Stephen on
Hi, I'm using xlswrite to transport a matrix from MATLAB to Excel. I want my output in the Excel file to be in the format of dollars and cents (hence, only to two decimal places). However, MATLAB is sending it to Excel in four decimal places. I've tried using "format bank" and "fprintf". But, of course, fprintf won't work for the Excel file because it is not defined for cell inputs. Need some help please!
From: Claudio Pedrazzi on
have a look at this: I used it for a similar problem, and with a little patience, it works perfectly:

http://www.mathworks.com/support/solutions/en/data/1-33B9ZN/index.html?solution=1-33B9ZN
From: DitzaN on
Hi,
It is not really dealing the problem but it will solve the problem.
You can change the number you are writing to excel to be with two decimal places.
M=[1.8394 1.2453]
use
M1=round(M*100)/100;
Now write M1 instated of M
From: ImageAnalyst on
Stephen:
You can't do it using xlswrite() - it simply doesn't give you control
over all those kinds of fine details. You need to either
1) start Excel as an activeX process and set those cell properties via
active x methods and properties, (like in the link Claudio gave you)
or
2) open an existing spreadsheet where the formatting has already been
done in advance (i.e. you created a workbook in Excel and formatted
cells in Excel and saved it out, and then wrote to the same
spreadsheet via xlswrite()).
From: TideMan on
On Nov 26, 5:00 am, ImageAnalyst <imageanal...(a)mailinator.com> wrote:
> Stephen:
> You can't do it using xlswrite() - it simply doesn't give you control
> over all those kinds of fine details.  You need to either
> 1) start Excel as an activeX process and set those cell properties via
> active x methods and properties, (like in the link Claudio gave you)
> or
> 2) open an existing spreadsheet where the formatting has already been
> done in advance (i.e. you created a workbook in Excel and formatted
> cells in Excel and saved it out, and then wrote to the same
> spreadsheet via xlswrite()).

or
3) use fprintf to write to a .csv file in the desired format and
import the .csv file into Excel.