声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 5618|回复: 9

[编程技巧] 如何把一个字符串写到excel的一个格子里面

[复制链接]
发表于 2007-10-13 11:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
如何把一个字符串写到excel的一个格子里面
m文件代码
%%%向w.xls文件写入10%
m=strcat(num2str(round(10)),'%');
xlswrite('w.xls',m,'sheet1','a1:c10');
黄颜色数据是写入结果,每个字符占一列,红颜色的是我的预期结果(自己手动输入的),10%占一列。我哪个地方弄错了

[ 本帖最后由 lxq 于 2007-10-13 16:23 编辑 ]
Snap1.jpg
回复
分享到:

使用道具 举报

发表于 2007-10-13 13:18 | 显示全部楼层
以后好好用doc命令吧:
doc xlswrite

Example 2 — Writing Mixed Data to a Specific WorksheetThis example writes the following mixed text and numeric data to the
file tempdata.xls:d = {'Time', 'Temp'; 12 98; 13 99; 14 97};Call xlswrite, specifying the worksheet
labeled Temperatures, and the region within the worksheet
to write the data to. The 4-by-2 matrix will be written to the rectangular
region that starts at cell E1 in its upper left corner:s = xlswrite('tempdata.xls', d, 'Temperatures', 'E1')
s =
    1The output status s shows that the write operation
succeeded. The data appears as shown here in the output file:
Time   Temp
  12     98
  13     99
  14     97

你的问题答案:
m=cellstr(strcat(num2str(round(10)),'%'));
xlswrite('w.xls',m,'sheet1','a1:a10');

评分

1

查看全部评分

发表于 2007-10-13 13:58 | 显示全部楼层
前辈高人,以后多来本版哈:handshake
发表于 2007-10-13 15:59 | 显示全部楼层
这样也可以吧!
m={'10%'};
xlswrite('w.xls',m,'a1:a10');
发表于 2007-10-13 16:10 | 显示全部楼层

回复 #4 home96 的帖子

是一样的,心灯院长的用得用得更普遍些
 楼主| 发表于 2007-10-13 16:11 | 显示全部楼层
晕,关键是计算出来的,楼上的方法肯定行不通,楼上的只能输固定的,计算的就不行了
发表于 2007-10-13 16:14 | 显示全部楼层

回复 #6 94117239 的帖子

2楼正解啊,我都说了4楼的用法不普遍了
 楼主| 发表于 2007-10-13 16:26 | 显示全部楼层
已经做成了,谢谢楼上几位帮助,
发表于 2009-2-1 14:04 | 显示全部楼层
O(∩_∩)O谢谢前辈的指点,启发很大!!!
发表于 2009-2-1 21:47 | 显示全部楼层
EXCEL中一样可以实现,另外MATLAB中那个百分号可以不要。
在C1内输入(MATLAB代码中已经提示源数据写入从a1单元格开始):
  1. =A1&B1&"%"
复制代码
最后下拉复制公式。

评分

2

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-7 16:17 , Processed in 0.062764 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表