matlab 写word文档,用Matlab生成Word文档
用Matlab生成Word文档用Matlab编了一段程序,可以生成Word文档,文档中含有表格,代码如下:
filespec = 'C:\Documents and
Settings\Administrator\桌面\xiezh.doc';
try;
Word=actxGetRunningServer('Word.Application');
catch;
Word =
actxserver('Word.Application');
end;
set(Word, 'Visible', 1);
documents = Word.Documents;
if exist(filespec,'file')
document =
invoke(documents,'Open',filespec);
else
document = invoke(documents, 'Add');
document.SaveAs(filespec);
end
content = document.Content;
duplicate = content.Duplicate;
inlineshapes = content.InlineShapes;
selection = Word.Selection;
paragraphformat = selection.ParagraphFormat;
%页面设置
document.PageSetup.TopMargin = 60;
document.PageSetup.BottomMargin = 45;
document.PageSetup.LeftMargin = 45;
document.PageSetup.RightMargin = 45;
set(content, 'Start',0);
title='试 卷 分 析';
set(content, 'Text',title);
set(paragraphformat,
'Alignment','wdAlignParagraphCenter');
rr=document.Range(0,10);
rr.Font.Size=16;
rr.Font.Bold=4;
end_of_doc = get(content,'end');
set(selection,'Start',end_of_doc);
selection.TypeParagraph;
set(selection, 'Text','(20
—20
学年 第
学期)');
selection.Font.Size=12;
selection.MoveDown;
set(paragraphformat,
'Alignment','wdAlignParagraphCenter');
selection.TypeParagraph;
selection.TypeParagraph;
selection.Font.Size=10.5;
Tables=document.Tables.Add(selection.Range,12,9);
%设置边框
DTI=document.Tables.Item(1);
DTI.Borders.OutsideLineStyle='wdLineStyleSingle';
DTI.Borders.OutsideLineWidth='wdLineWidth150pt';
DTI.Borders.InsideLineStyle='wdLineStyleSingle';
DTI.Borders.InsideLineWidth='wdLineWidth150pt';
DTI.Rows.Alignment='wdAlignRowCenter';
DTI.Rows.Item(8).Borders.Item(1).LineStyle='wdLineStyleNone';
DTI.Rows.Item(8).Borders.Item(3).LineStyle='wdLineStyleNone';
DTI.Rows.Item(11).Borders.Item(1).LineStyle='wdLineStyleNone';
DTI.Rows.Item(11).Borders.Item(3).LineStyle='wdLineStyleNone';
column_width=[53.7736,80.9434,53.7736,29.0094,29.0094,76.6981,55.1887,52.9245,54.9057];
row_height=[28.5849,28.5849,28.5849,28.5849,25.4717,25.4717,32.8302,312.1698,17.8302,49.2453,14.1509,18.6792];
for i=1:9
DTI.Columns.Item(i).Width =column_width(i);
end
for i=1:12
DTI.Rows.Item(i).Height =row_height(i);
end
for i=1:12
for j=1:9
DTI.Cell(i,j).VerticalAlignment='wdCellAlignVerticalCenter';
end
end
DTI.Cell(1, 4).Merge(DTI.Cell(1, 5));
DTI.Cell(2, 4).Merge(DTI.Cell(2, 5));
DTI.Cell(3, 4).Merge(DTI.Cell(3, 5));
DTI.Cell(4, 4).Merge(DTI.Cell(4, 5));
DTI.Cell(5, 2).Merge(DTI.Cell(5, 5));
DTI.Cell(5, 3).Merge(DTI.Cell(5, 6));
DTI.Cell(6, 2).Merge(DTI.Cell(6, 5));
DTI.Cell(6, 3).Merge(DTI.Cell(6, 6));
DTI.Cell(5, 1).Merge(DTI.Cell(6, 1));
DTI.Cell(7, 1).Merge(DTI.Cell(7, 9));
DTI.Cell(8, 1).Merge(DTI.Cell(8, 9));
DTI.Cell(9, 1).Merge(DTI.Cell(9, 3));
DTI.Cell(9, 2).Merge(DTI.Cell(9, 3));
DTI.Cell(9, 3).Merge(DTI.Cell(9, 4));
DTI.Cell(9, 4).Merge(DTI.Cell(9, 5));
DTI.Cell(10, 1).Merge(DTI.Cell(10, 9));
DTI.Cell(11, 5).Merge(DTI.Cell(11, 9));
DTI.Cell(12, 5).Merge(DTI.Cell(12, 9));
DTI.Cell(11, 1).Merge(DTI.Cell(12, 4));
end_of_doc = get(content,'end');
set(selection,'Start',end_of_doc);
selection.TypeParagraph;
set(selection, 'Text','主管院长签字: 年 月 日');
set(paragraphformat,
'Alignment','wdAlignParagraphRight');
DTI.Cell(1,1).Range.Text = '课程名称';
DTI.Cell(1,3).Range.Text = '课程号';
DTI.Cell(1,5).Range.Text = '任课教师学院';
DTI.Cell(1,7).Range.Text = '任课教师';
DTI.Cell(2,1).Range.Text = '授课班级';
DTI.Cell(2,3).Range.Text = '考试日期';
DTI.Cell(2,5).Range.Text = '应考人数';
DTI.Cell(2,7).Range.Text = '实考人数';
DTI.Cell(3,1).Range.Text = '出卷方式';
DTI.Cell(3,3).Range.Text = '阅卷方式';
DTI.Cell(3,5).Range.Text = '选用试卷A/B';
DTI.Cell(3,7).Range.Text = '考试时间';
DTI.Cell(4,1).Range.Text = '考试方式';
DTI.Cell(4,3).Range.Text = '平均分';
DTI.Cell(4,5).Range.Text = '不及格人数';
DTI.Cell(4,7).Range.Text = '及格率';
DTI.Cell(5,1).Range.Text = '成绩分布';
DTI.Cell(5,2).Range.Text = '90分以上
人占
%';
DTI.Cell(5,3).Range.Text = '80---89分
人占
%';
DTI.Cell(6,2).Range.Text = '70--79分
人占
%';
DTI.Cell(6,3).Range.Text = '60---69分
人占
%';
DTI.Cell(7,1).Range.Text =
'试卷分析(含是否符合教学大纲、难度、知识覆盖面、班级分数分布分析、学生答题存在的共性问题与知识掌握情况、教学中存在的问题及改进措施等内容)';
DTI.Cell(7,1).Range.ParagraphFormat.Alignment='wdAlignParagraphLeft';
DTI.Cell(9,2).Range.Text = '签字 :';
DTI.Cell(9,4).Range.Text = '年 月 日';
DTI.Cell(10,1).Range.Text = '教研室审阅意见:';
DTI.Cell(10,1).Range.ParagraphFormat.Alignment='wdAlignParagraphLeft';
DTI.Cell(10,1).VerticalAlignment='wdCellAlignVerticalTop';
DTI.Cell(11,2).Range.Text = '教研室主任(签字):
年 月 日';
DTI.Cell(11,2).Range.ParagraphFormat.Alignment='wdAlignParagraphLeft';
DTI.Cell(8,1).Range.ParagraphFormat.Alignment='wdAlignParagraphLeft';
DTI.Cell(8,1).VerticalAlignment='wdCellAlignVerticalTop';
DTI.Cell(9,2).Borders.Item(2).LineStyle='wdLineStyleNone';
DTI.Cell(9,2).Borders.Item(4).LineStyle='wdLineStyleNone';
DTI.Cell(9,3).Borders.Item(4).LineStyle='wdLineStyleNone';
DTI.Cell(11,1).Borders.Item(4).LineStyle='wdLineStyleNone';
matlab 写word文档,用Matlab生成Word文档相关推荐
- Java读取word模板,并动态生成word
Java读取word模板,并动态生成word 最近有个需求是将数据库里存入的用户个人信息生成一个word然后供用户下载,第一时间就就想到了poi来做,所以记录一下免得自己忘了,忘了也可以回来看看
- 根据 Excel 数据表的内容和 Word 模板文件,批量生成 Word 文档
概要:想必大家都遇到过批量生成 Word 文件的场景.我们这里有一个 Excel 数据表,那么如何根据这个数据表批量地生成 Word 文件呢?有一种方法就是我们常见的邮件合并,但是邮件合并的操作步骤太 ...
- php实现生成word表格,TP5利用phpforword生成word表格文档
TP5利用phpforword生成word表格文档 2019-12-18 573 1.首先用composer安装下载 phpoffice/phpforwordcomposer require phpo ...
- h5页面打开word文档ios_H5页面生成word文件及发送邮件
最近工作中有用到生成word文档及发送该附件的邮件.先说说我的思路和流程吧; 1.在后台用PHP将数据组合拼接成HTML格式: 2.生成带数据(HTML)的word文档(生成到项目对应的目录下): 3 ...
- php如何生成本地文档,php如何生成word文件
php生成word文件的方法: 需求: 甲方爸爸说"我有一个word文件,里面是关于用户信息的表格,你帮我把系统里面所有用户数据都按照这个文件导出来给我": 我当时就不乐意了,啪的 ...
- poi-tl生成word文档,java生成word文档
模板中变量,请参考api中5.标签 实例请参考10.实例 每个实例最后有源码地址:https://github.com/Sayi/poi-tl/tree/v1.9.0 本人配置: jdk:1.8 依赖 ...
- php导出word试卷,实例:PHP生成word文档格式试卷的代码
//初始化session session_start(); // 包含数据库连接文件和头文件 ?> 试卷生成 include('head.php'); require ('dbconnect.p ...
- c语言调用pdf文档,使用PDFLib生成PDF文档方法介绍(C语言版)
本文简单介绍了PDFLib生成PDF文档(C语言版)的基本使用方法. 1.基本环境 ① 打开.关闭.文档信息设定: 新建PDFLib对象,PDF_new() 设定错误处理的方式,PDF_set_par ...
- php操作pdf文档输出,PHP生成PDF文档实用技巧
PHP生成PDF文档实用技巧 实际工作中,我们要使用PHP动态的创建PDF文档,目前有许多开源的PHP创建PDF的类库,今天我给大家来介绍一款优秀的PDF库,它就是TCPDF,TCPDF是一个用于快速 ...
- Python操作word手册,与打包生成word文件
title: Python操作word手册 copyright: true top: 0 date: 2018-11-23 14:59:03 tags: python-word categories: ...
最新文章
- C语言文件操作函数大全
- python networkx模块,python复杂网络处理模块networkx
- “鹅厂养鹅”是假的,但腾讯这个“山洞”是真的
- axure怎么做手机app界面_iPhone11手机APP频繁闪退怎么办?
- python单/双下划线使用
- ubuntu16.04安装驱动
- day14ARP协议、路由原理、ARP实验、ARP防御、2003虚拟机如何关闭定时锁屏
- Tomcat的starup.bat报错问题解决
- 《安富莱嵌入式周报》第231期:2021.09.20--2021.09.26
- sql语句动态拼接多个查询条件查询数据库
- 三相 AC-DC 变换电路(B 题)-- 2021 年全国大学生电子设计竞赛
- 信息安全快讯丨秋风乍起,微雨渐凉
- 你有没有感觉现在4G的速度越来越慢了?为什么?
- SIMCom芯片关于GPS定位信息的的解析(AT+CGNSINF)
- 来自 Google 的高可用架构理念与实践
- Windows下Core Audio APIS 音频应用开发(五)
- 因果推理综述—基于论文《A Survey on Causal Inference》总结
- 2017最新版SCI期刊目录发布
- go: finding module for package
- “三体”域名纠纷案受关注,企业应如何做好域名品牌保护?