Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Writing numbers as text to Excel from Matlab
Date: Thu, 8 Oct 2009 20:40:23 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 30
Message-ID: <halinn$gtf$1@fred.mathworks.com>
References: <hal75n$r6$1@fred.mathworks.com> <c7fedc7c-e966-487d-8d5f-8c2880a3e879@h30g2000vbr.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1255034423 17327 172.30.248.37 (8 Oct 2009 20:40:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 8 Oct 2009 20:40:23 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1560446
Xref: news.mathworks.com comp.soft-sys.matlab:576066


Thanks for your help Rune. In the meantime i found a way to do it! Using a for loop, I converted the numbers as follows
  excel_table(a,b)=strcat('''',old_table(a,b));
I then used xlswrite with excel_table and that worked.


Rune Allnor <allnor@tele.ntnu.no> wrote in message <c7fedc7c-e966-487d-8d5f-8c2880a3e879@h30g2000vbr.googlegroups.com>...
> 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