浩天教育致力于打造优质Essay代写、Assignment代写机构,「新客首单立减5%」长期有效!

HotEssay论文网 - 新闻动态 - 写作技巧 - Matlab代写如何自动生成word报告
新闻动态
最新发布
热门文章
联系我们
写作技巧

Matlab代写如何自动生成word报告

来源:原创 发布日期:2021-02-25 15:38  阅读: 作者:HotEssay
文章导读:在工作中,需要经常性地每天做一些数据上的统计分析报告。虽然用excel也能够做,但是终究还是要手工刷新Excel插件数据。虽然工作量不大,但毕竟繁琐。好在有matlab, Matlab代写 可以...

  在工作中,需要经常性地每天做一些数据上的统计分析报告。虽然用excel也能够做,但是终究还是要手工刷新Excel插件数据。虽然工作量不大,但毕竟繁琐。好在有matlab,Matlab代写可以抓取网页上的内容、读取Excel的东西、访问和读写SqlServer数据库,创建和编辑Word文档。通过相互之间的访问调用,可以自动生成Word报告,无需任何人工的操作。大大节约了时间。(excel表格,在实际使用过程中,可以利用SqlServer数据库,自动计算出Excel的结果。)

  效果如图示:

matlab代写

  操作方法:

  %%一、成word文本

  %设定测试Word文件名和路径

  filespec_user=[pwd'createword.doc'];

  %判断Word是否已经打开,若已打开,就在打开的Word中进行操作,否则就打开Word

  try

  %若Word服务器已经打开,返回其句柄Word

  Word=actxGetRunningServer(‘Word.Application’);

  catch

  %创建一个Microsoft Word服务器,返回句柄Word

  Word=actxserver(‘Word.Application’);

  end;

  %设置Word属性为可见

  %或set(Word,‘Visible’,1);

  Word.Visible=1;

  %若测试文件存在,打开该测试文件,否则,新建一个文件,并保存,文件名为测试.doc

  if exist(filespec_user,’file’);

  Document=Word.Documents.Open(filespec_user);

  %Document=invoke(Word.Documents,’Open’,filespec_user);

  else

  Document=Word.Documents.Add;

  %Document=invoke(Word.Documents,‘Add’);

  Document.SaveAs2(filespec_user);

  end

  %返回Content接口句柄

  Content=Document.Content;

  %返回Selection接口句柄

  Selection=Word.Selection;

  %返回ParagraphFormat接口句柄

  Paragraphformat=Selection.ParagraphFormat;

  %页面设置

  %上边距60磅

  Document.PageSetup.TopMargin=60;

  %下边距45磅

  Document.PageSetup.BottomMargin=45;

  %左边距45磅

  Document.PageSetup.LeftMargin=45;

  %右边距45磅

  Document.PageSetup.RightMargin=45;

  Document.PageSetup.HeaderDistance=185;

  Document.Paragraphs.FirstLineIndent=25;%首行缩进

  %设定文档内容的起始位置和标题

  %设置文档内容的起始位置

  Content.Start=100;

  str2=’仍以震荡为主’;%%★文章标题

  title=str2;

  %输入文字内容

  Content.Text=title;

  %设置字号为16

  Content.Font.Size=18;

  %字体加粗

  Content.Font.Bold=4;

  %居中对齐

  Content.Paragraphs.Alignment=‘wdAlignParagraphCenter’;

  %设定下面内容的起始位置

  Selection.Start=Content.end;

  %回车,另起一段

  Selection.TypeParagraph;

  sczhfx=’市场综合分析:’;

  %在当前位置输入文字内容

  Selection.Text=sczhfx;

  %设置字号为1

  Selection.Font.Size=12;

  Selection.Font.Bold=4;%字体不加粗

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.Start=Content.end;%设定内容起始位置在标题后面

  Selection.MoveDown;%光标下移(取消选中)

  Selection.TypeParagraph;

  %设置“市场综合分析内容”

  %市场综合分析第1段

  sczhfx1=’沪深两市指数双双小幅低开,随后出现震荡走势,沪深指数早盘一度翻红,但午后出现大跌,沪指更是一度大跌逾1%,但创业板指仍旧保持强势行情,盘中一度突破2400点,再创历史新高。从盘面来看,银行板块表现最差,16只银行股全线下跌,钢铁股表现也不佳,仅有4只钢铁股飘红。此外,航空,保险,电力,有色,煤炭,券商等权重板块尽数表现不佳,成为沪指下跌的主要因素。’;

  Selection.Text=sczhfx1;

  Selection.Font.Size=10;

  Selection.Font.Bold=0;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.MoveDown;

  Selection.TypeParagraph;

  %市场综合分析第2段

  sczhfx2=’技术面来看,周三大盘呈现调整走势,虽然量能萎缩,但成交额依然保持万亿以上,所以大盘调整的幅度不深,同时也说明了大盘开始出现滞涨的苗头,预计大盘短期仍将保持这种震荡整理的格局。’;

  Selection.Text=sczhfx2;

  Selection.Font.Size=10;

  Selection.Font.Bold=0;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.MoveDown;

  Selection.TypeParagraph;

  Selection.TypeParagraph;

  %设置“融资融券投资策略”

  rzrqtzcl=’融资融券投资策略’;

  Selection.Text=rzrqtzcl;

  Selection.Font.Size=12;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.Font.Bold=4;

  Selection.MoveDown;

  Selection.TypeParagraph;

  %设置“看好行业”标题

  khhy=’看好行业:’;

  Selection.Text=khhy;

  Selection.Font.Size=11;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.Font.Bold=4;

  Selection.Start=Selection.end;

  %设置“看好行业”内容

  khhynr=’新增资金入场更倾向于趋势明确流动性好的大盘股,继续看好的行业:地产、医药、汽车、白电、白酒、铁路设备。’;

  Selection.Text=khhynr;

  Selection.Font.Size=10;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.Font.Bold=0;

  Selection.MoveDown;

  Selection.TypeParagraph;

  %设置“看好行业”标题

  kkhy=’看空行业:’;

  Selection.Text=kkhy;

  Selection.Font.Size=11;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.Font.Bold=4;

  Selection.MoveDown;

  Selection.Start=Selection.end;

  %设置“看空行业”内容

  kkhynr=’煤炭。’;

  Selection.Text=kkhynr;

  Selection.Font.Size=10;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.Font.Bold=0;

  Selection.MoveDown;

  Selection.TypeParagraph;

  %设置“看好行业”标题

  jrjy=’今日建议:’;

  Selection.Text=jrjy;

  Selection.Font.Size=11;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.Font.Bold=4;

  Selection.MoveDown;

  Selection.Start=Selection.end;

  %设置“今日建议”内容

  jrjynr=’短期大盘高位震荡预计仍将维持。建议激进投资者关注一路一带、智能家居、智能穿戴和3D打印板块,稳健投资者可维持五成左右仓位。’;

  Selection.Text=jrjynr;

  Selection.Font.Size=10;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.Font.Bold=0;

  Selection.MoveDown;

  Selection.TypeParagraph;

  Selection.TypeParagraph;

  %%设置融资组合

  %设置“融资组合”标题

  rzzh=’融资组合’;

  Selection.Text=rzzh;

  Selection.Font.Size=12;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;%左对齐

  Selection.Font.Bold=4;

  Selection.MoveDown;

  Selection.Start=Selection.end;

  kg=”;%调整格式

  Selection.Text=kg;

  Selection.Font.Size=10;

  Selection.paragraphformat.Alignment=‘wdAlignParagraphLeft’;

  Selection.Font.Bold=0;

  Selection.MoveDown;

  Selection.TypeParagraph;

  %插入表格:融资组合股票表现

  rzzhbx=Document.Tables.Add(Selection.Range,12,8);

  rzzh=Document.Tables.Item(1);%插入的表格数(第1个)

  %rqzh=Document.Tables.Add(Document.Paragraphs.Item(2).Range,2,2);%在第2个段落插入2行2列表格,并覆盖第2段。

  rzzh.Borders.OutsideLineStyle=’wdLineStyleSingle’;%增加外边框

  rzzh.Borders.InsideLineStyle=’wdLineStyleSingle’;%增加内边框

  rzzh.Borders.OutsideLineWidth=‘wdLineWidth075pt’;%设置线宽,有025,050,075,100,150,225,300,450,600pt等

  rzzh.Rows.Alignment=‘wdAlignRowCenter’;%居中对齐

  rzzh.Columns.Item(1).Width=55;

  rzzh.Columns.Item(2).Width=50;

  rzzh.Columns.Item(3).Width=59;

  rzzh.Columns.Item(4).Width=59;

  rzzh.Columns.Item(5).Width=55;

  rzzh.Columns.Item(6).Width=55;

  rzzh.Columns.Item(7).Width=62;

  rzzh.Columns.Item(8).Width=110;

  %%rzzh.Columns.Item(3).Height=18;

  rzzh.Cell(1,1).Merge(rzzh.Cell(1,8));%合并单元格

  rzzh.Cell(1,1).Range.Text=‘图表1:融资组合股票表现(股票数:10)’;

  rzzh.Cell(2,1).Range.Text=‘公司’;

  rzzh.Cell(2,2).Range.Text=‘代码’;

  rzzh.Cell(2,3).Range.Text=‘调入日期’;

  rzzh.Cell(2,4).Range.Text=‘最新价(元)’;

  rzzh.Cell(2,5).Range.Text=‘流通市值’;

  rzzh.Cell(2,6).Range.Text=‘收益率(%)’;

  rzzh.Cell(2,7).Range.Text=‘最高收益率’;

  rzzh.Cell(2,8).Range.Text=‘推荐理由’;

  %提取excel里的数据

  [a,b,c]=xlsread(‘rzrq.xlsx’);

  for i=1:10

  for j=1:8

  rzzh.Cell(i+2,j).Range.Text=char(cellstr(c(i+1,j)));

  end

  end

本文关键词:Matlab代写 想了解更多关于Matlab代写的文章请点击:Matlab代写

特别声明:本站文章内容来源于本站原创以及网络整理,旨在帮助留学生学会如何写留学作业论文以顺利完成学业之目的,部分留学论文作业格式范文及内容仅供参考学习之用。如本站文章和转稿涉及版权等问题,请作者及时联系本站,我站将在第一时间予以删除。
本文标题: Matlab代写如何自动生成word报告       本文地址:http://www.toutiaoliuxue.com/news/writingskills/634.html
相关资讯
范文案例
相关评论
说点什么吧
  • 全部评论(0
X微信二维码

截屏,微信识别二维码

微信号:hotessay1

(点击微信号复制,添加好友)

微信号已复制,请打开微信添加好友!