注意事项

上一篇已经说明,这次就不一一说了,直接来正文;

word内容

相关代码

方法1

  static void Main(string[] args)
{
string wordPathStr = @"C:\Users\user\Desktop\新建文件夹 (2)\openxml读取表格内容.docx";
using (WordprocessingDocument doc = WordprocessingDocument.Open(wordPathStr, true))
{
Body body = doc.MainDocumentPart.Document.Body;
foreach (var table in body.Elements<Table>())
{
foreach (var tableRow in table.Elements<TableRow>())
{
foreach (var tableCell in tableRow.Elements<TableCell>())
{
Console.Write(tableCell.InnerText);
}
}
}
} Console.ReadKey();
}

  static void Main(string[] args)
{
string wordPathStr = @"C:\Users\user\Desktop\新建文件夹 (2)\openxml读取表格内容.docx";
using (WordprocessingDocument doc = WordprocessingDocument.Open(wordPathStr, true))
{
Body body = doc.MainDocumentPart.Document.Body;
var tableCellList=body.Elements<OpenXmlElement>();
foreach (var table in body.Elements<Table>())
{
foreach (var tableRow in table.Elements<TableRow>())
{
Console.Write(tableRow.InnerText);
}
}
}
Console.ReadKey();
}

  static void Main(string[] args)
{
string wordPathStr = @"C:\Users\user\Desktop\新建文件夹 (2)\openxml读取表格内容.docx";
using (WordprocessingDocument doc = WordprocessingDocument.Open(wordPathStr, true))
{
Body body = doc.MainDocumentPart.Document.Body;
var tableCellList=body.Elements<OpenXmlElement>();
foreach (var table in body.Elements<Table>())
{
Console.Write(table.InnerText);
}
}
Console.ReadKey();
}

方法2

     static void Main(string[] args)
{
string wordPathStr = @"C:\Users\user\Desktop\新建文件夹 (2)\openxml读取表格内容.docx";
using (WordprocessingDocument doc = WordprocessingDocument.Open(wordPathStr, true))
{
Body body = doc.MainDocumentPart.Document.Body;
var tableCellList = body.Elements<OpenXmlElement>();
foreach (var inst in tableCellList)
{
Console.Write(inst.InnerText);
}
} Console.ReadKey();
}

注:方法1和方法2使用场景,以后慢慢来介绍;

控制台显示

OpenXml读取word内容(二)的更多相关文章

  1. OpenXml读取word内容(一)

    OpenXml读取word内容注意事项 1.使用OpenXml读取word内容,word后缀必须是".docx":如果word后缀是".doc"需要转成&quo ...

  2. OpenXml读取word内容注意事项

    OpenXml读取word内容注意事项 1.使用OpenXml读取word内容,word后缀必须是".docx":如果word后缀是".doc"需要转成&quo ...

  3. OpenXml读取word内容(三)

    内容和表格内容一起读: word内容: 代码: public static void ReadWordByOpenXml(string path) { using (WordprocessingDoc ...

  4. java读取word内容

    暂时只写读取word内容的方法. 依赖的jar: poi-3.9-20121203.jarpoi-ooxml-3.9-20121203.jarxmlbeans-2.3.0.jar package co ...

  5. python如何转换word格式、读取word内容、转成html

    # python如何转换word格式.读取word内容.转成html? import docx from win32com import client as wc # 首先将doc转换成docx wo ...

  6. C#读取word内容实践

    C#读取word文档是如何实现的呢?我们可以使用FileStream对象来把文本文件里面的信息读取出来,但是对于word文档来说就不能使用这样的方法了. 这种情况下C#读取word文档的实现我们需要使 ...

  7. c#读取word内容,c#提取word内容

    Post by 54admin, 2009-5-8, Views:575 1: 对项目添加引用,Microsoft Word 11.0 Object Library 2: 在程序中添加 using W ...

  8. C# 读取Word内容控件

    在Word中,借助内容控件,可设计出具有特定功能的文档或模板.以下表格中简单介绍了几种常用的内容控件. 名称 简介 下拉列表内容控件 下拉列表包含了一个预先定义好的列表.和组合框不同的是下拉列表不允许 ...

  9. 我的第八个java程序--读取word内容

    package World; import java.io.FileNotFoundException; import java.io.IOException; import org.apache.p ...

随机推荐

  1. poj 1254 Hansel and Grethel

    Hansel and Grethel Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2199   Accepted: 100 ...

  2. MySQLbase

    /*多行注释*/-- 单行注释-- 创建用户: CREATE USER '用户名'[@'主机名'] IDENTIFIED BY '密码'-- 主机名可以为空,省略主机名表示默认权限为%, 所有主机都可 ...

  3. Vue.js用法详解(一)更新中~

      前  言 前段时间为了一个数据查询的项目自学了Vue,感觉这款框架还是很不错的,今天就整理整理这个框架如何使用,希望对正在学这个框架的小伙伴有所帮助~ 首先,我们先来了解一下Vue: Vue.js ...

  4. AutoMapper IIS回收引发的 未将对象引用设置到对象实例

    一.前言 最近使用AutoMapper的时候,一段时间久会产生System.NullReferenceException:未将对象引用设置到对象的实例.这个问题.后来通过测试,发现部署在IIS上的站点 ...

  5. 532. K-diff Pairs in an Array

    Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in t ...

  6. win10出现"本地计算机上的MySQL57服务启动后停止"

    在window10下mysql57出现"本地计算机上的MySQL57服务启动后停止.某些服务在未由其他服务或程序使用时将自动停止"错误 环境:win10.MySQL Communi ...

  7. 通过PING命令中的TTL来判断对方操作系统

    ---恢复内容开始--- 通过PING命令中的TTL来判断对方操作系统简单来说,TTL全程Time to Live,意思就是生存周期.首先要说明ping命令是使用的网络层协议ICMP,所以TTL指的是 ...

  8. [转载] Mahout

    转载自http://hadoop.readthedocs.org/en/latest/Hadoop-Mahout.html# Mahout 12.1 简介 Mahout为推荐引擎提供了一些可扩展的机器 ...

  9. System.Transactions 事务超时属性

    最近遇到一个处理较多数据的大事务,当进行至10分钟左右时,爆出事务超时异常,如果Machine.config中不设置最大超时时间,则默认超时时间为10分钟 MachineSettingsSection ...

  10. javascript 的继承

    我们的JavaScript比较特别了,主要通过原型链实现继承的. 下面介绍各种实现继承的方式:原型链继承,借用构造函数,组合继承,原型式继承,寄生式继承,寄生组合式继承. 二.实现继承方式 1.原型链 ...