注意事项

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

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. A Walk Through the Forest

    A Walk Through the Forest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...

  2. awk练习题

    1. sed和awk有什么区别? (1)awk:按列(域)操作:sed:按行操作 (2)awk:文本处理语言,适合对文本进行抽取处理:sed:非交互式的编辑器,适合对文本进行编辑 2. awk要处理域 ...

  3. AngularJS学习篇(十六)

    AngularJS 表单 HTML 控件 以下 HTML input 元素被称为 HTML 控件: input 元素 select 元素 button 元素 textarea 元素 HTML 表单 H ...

  4. BOM对象

    每一个frames都有自己的window对象,也就是每个frames都有自己的全局对象,它们之前是相互独立的,包括各自独立的本地对象,top.Object !== top.frames[0].Obje ...

  5. 【转】解决memcached启动失败

    原文:http://chenzhou123520.iteye.com/blog/1925196 linux上启动Memcache报错: 原因一般有两个, 一个是操作系统里确实没有包含该共享库(lib* ...

  6. JavaScript系列----函数(Function)篇(4)

    1.什么是函数? 在W3C中函数的定义是这么说的:函数是由事件驱动的或者当它被调用时执行的可重复使用的代码块.   诚然,从这种抽象的定义中我们得不到什么有价值的东西.下面,举例来列举出函数的几种定义 ...

  7. [java语言]——InetAddress类的getByName()方法

    InetAddress---表示互联网协议(IP)地址 ---InetAddress.getByName("www.163.com")----在给定主机名的情况下确定主机的IP地址 ...

  8. java二维码生成

    import java.io.File; import java.nio.file.Path; import java.util.HashMap; import com.google.zxing.Ba ...

  9. java.io.File类操作

    一.java.io.File类 String path="E:/222/aaa";//路径 String path1="aaa.txt"; File file= ...

  10. C#模拟登录总结

    /// <summary>  登录        /// </summary>        /// <param name="url">< ...