Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!h30g2000vbr.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Writing numbers as text to Excel from Matlab
Date: Thu, 8 Oct 2009 11:04:10 -0700 (PDT)
Organization: http://groups.google.com
Lines: 28
Message-ID: <c7fedc7c-e966-487d-8d5f-8c2880a3e879@h30g2000vbr.googlegroups.com>
References: <hal75n$r6$1@fred.mathworks.com>
NNTP-Posting-Host: 77.17.11.235
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1255025050 10409 127.0.0.1 (8 Oct 2009 18:04:10 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 8 Oct 2009 18:04:10 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: h30g2000vbr.googlegroups.com; posting-host=77.17.11.235; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
	Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; 
	.NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:576018


On 8 Okt, 19:23, "Conrad " <conr...@gmx.net> wrote:
> Hi,
>
> I have a cell array containing text and numbers. Among the numbers, some have decimals and others don't. To keep things simple, I have all the numbers as text and I am trying to send this cell array to an Excel file. XLSWRITE converts all the '1.0' data to '1'. Having looked around, I thought PutCellValue (by Michael Robbins) would do it:
>
>   sheet1=Excel.Worksheets.get('Item', 'Sheet1');
>   range=get(sheet1,'Range', 'A1');
>   PutCellValue(range,'1.0',1);
>
> but I still get the value of 1 on the Excel Sheet. Any ideas?
> Thanks

This is just as much a problem with display otions in Excel
as with the numerical values. Record a macro in excel where
you select the display format you want. Then open the macro
in the editor, and look at the commands that were used to
set the display options. Last, insert the same commands
at the matlab side when you write the excel file.

It should be something like

range.set('numberformat','0.00');

Rune