当前位置:编程学习 > C#/ASP.NET >>

c# 读取word中不规则表格

网上面的代码都是读取的规格表格。没有合并单元格代码的读取
eg
object oFileName = @"E:\互联网\WordReadAndWrite.docx";
                object oReadOnly = true;
                object oMissing = System.Reflection.Missing.Value;

                Microsoft.Office.Interop.Word.ApplicationClass app = new Microsoft.Office.Interop.Word.ApplicationClass();
                app.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;


                Microsoft.Office.Interop.Word._Application oWord;
                Microsoft.Office.Interop.Word._Document oDoc;
                oWord = new Microsoft.Office.Interop.Word.Application();
                // oWord.Visible = true;//只是为了方便观察
                oDoc = oWord.Documents.Open(ref oFileName, ref oMissing, ref oReadOnly, ref oMissing, ref oMissing,
    ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
    ref oMissing, ref oMissing, ref oMissing, ref oMissing);

                //读取文本信息

                //读取正常表格
                for (int tabPos = 1; tabPos <= oDoc.Tables.Count; tabPos++)
                {
                    Microsoft.Office.Interop.Word.Table nowTable = oDoc.Tables[tabPos];
                    for (int rowPos = 1; rowPos <= nowTable.Rows.Count; rowPos++)
                    {
                        for (int colPos = 1; colPos <= nowTable.Columns.Count; colPos++)
                        {
                            showMessage += nowTable.Cell(rowPos, colPos).Range.Text;
                            
                            showMessage = showMessage.Remove(showMessage.Length - 2, 2);
                            showMessage += "\t";
                        }
                        showMessage += "<br>";
                    }

                    showMessage += "<br>"; C# Word --------------------编程问答-------------------- 网上网的列子都找遍了。木有相关代码 求大神 --------------------编程问答-------------------- 转成文本文件,或者html文件,用正则匹配 --------------------编程问答-------------------- 楼上说的好。转成html好点吧! --------------------编程问答--------------------
引用 2 楼 shawn_yang 的回复:
转成文本文件,或者html文件,用正则匹配
 有具体的列子吗? --------------------编程问答--------------------
引用 3 楼 removeLove 的回复:
楼上说的好。转成html好点吧!
 有具体列子吗?
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,