<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/262646</link>
    <title>MATLAB Central Newsreader - Writing numbers as text to Excel from Matlab</title>
    <description>Feed for thread: Writing numbers as text to Excel from Matlab</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 08 Oct 2009 17:23:03 -0400</pubDate>
      <title>Writing numbers as text to Excel from Matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/262646#685735</link>
      <author>Conrad </author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
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:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;sheet1=Excel.Worksheets.get('Item', 'Sheet1'); &lt;br&gt;
&amp;nbsp;&amp;nbsp;range=get(sheet1,'Range', 'A1');&lt;br&gt;
&amp;nbsp;&amp;nbsp;PutCellValue(range,'1.0',1);&lt;br&gt;
&lt;br&gt;
but I still get the value of 1 on the Excel Sheet. Any ideas?&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Thu, 08 Oct 2009 18:04:10 -0400</pubDate>
      <title>Re: Writing numbers as text to Excel from Matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/262646#685744</link>
      <author>Rune Allnor</author>
      <description>On 8 Okt, 19:23, &quot;Conrad &quot; &amp;lt;conr...@gmx.net&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 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:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &#160; sheet1=Excel.Worksheets.get('Item', 'Sheet1');&lt;br&gt;
&amp;gt; &#160; range=get(sheet1,'Range', 'A1');&lt;br&gt;
&amp;gt; &#160; PutCellValue(range,'1.0',1);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; but I still get the value of 1 on the Excel Sheet. Any ideas?&lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
This is just as much a problem with display otions in Excel&lt;br&gt;
as with the numerical values. Record a macro in excel where&lt;br&gt;
you select the display format you want. Then open the macro&lt;br&gt;
in the editor, and look at the commands that were used to&lt;br&gt;
set the display options. Last, insert the same commands&lt;br&gt;
at the matlab side when you write the excel file.&lt;br&gt;
&lt;br&gt;
It should be something like&lt;br&gt;
&lt;br&gt;
range.set('numberformat','0.00');&lt;br&gt;
&lt;br&gt;
Rune</description>
    </item>
    <item>
      <pubDate>Thu, 08 Oct 2009 20:40:23 -0400</pubDate>
      <title>Re: Writing numbers as text to Excel from Matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/262646#685791</link>
      <author>Conrad </author>
      <description>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&lt;br&gt;
&amp;nbsp;&amp;nbsp;excel_table(a,b)=strcat('''',old_table(a,b));&lt;br&gt;
I then used xlswrite with excel_table and that worked.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Rune Allnor &amp;lt;allnor@tele.ntnu.no&amp;gt; wrote in message &amp;lt;c7fedc7c-e966-487d-8d5f-8c2880a3e879@h30g2000vbr.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On 8 Okt, 19:23, &quot;Conrad &quot; &amp;lt;conr...@gmx.net&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; 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:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; ? sheet1=Excel.Worksheets.get('Item', 'Sheet1');&lt;br&gt;
&amp;gt; &amp;gt; ? range=get(sheet1,'Range', 'A1');&lt;br&gt;
&amp;gt; &amp;gt; ? PutCellValue(range,'1.0',1);&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; but I still get the value of 1 on the Excel Sheet. Any ideas?&lt;br&gt;
&amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This is just as much a problem with display otions in Excel&lt;br&gt;
&amp;gt; as with the numerical values. Record a macro in excel where&lt;br&gt;
&amp;gt; you select the display format you want. Then open the macro&lt;br&gt;
&amp;gt; in the editor, and look at the commands that were used to&lt;br&gt;
&amp;gt; set the display options. Last, insert the same commands&lt;br&gt;
&amp;gt; at the matlab side when you write the excel file.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; It should be something like&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; range.set('numberformat','0.00');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Rune</description>
    </item>
  </channel>
</rss>

