最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#獲取Word文檔中所有表格的實(shí)現(xiàn)代碼分享

 更新時(shí)間:2014年09月06日 08:36:50   投稿:junjie  
這篇文章主要介紹了C#獲取Word文檔中所有表格的實(shí)現(xiàn)代碼分享,小編親測(cè)可用,需要的朋友可以參考下

今天從數(shù)據(jù)庫(kù)生成了一份數(shù)據(jù)字典,但是沒有備注,所以需要程序把表格都讀出來。用到了下面的代碼,親測(cè)可用~~

object oFileName = @"F:\數(shù)據(jù)庫(kù).docx";
object oReadOnly = false ;
object oMissing = System.Reflection.Missing.Value;
 
Microsoft.Office.Interop.Word._Application oWord;
Microsoft.Office.Interop.Word._Document oDoc;
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = false;
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);
 
//MessageBox.Show(oDoc.Tables.Count.ToString());
for (int tablePos = 1; tablePos <= oDoc.Tables.Count; tablePos++)
{
  Microsoft.Office.Interop.Word.Table nowTable = oDoc.Tables[tablePos];
  string tableMessage = string.Format("第{0}/{1}個(gè)表:\n", tablePos, oDoc.Tables.Count);
 
  for (int rowPos = 1; rowPos <= nowTable.Rows.Count; rowPos++)
  {
    for (int columPos = 1; columPos <= nowTable.Columns.Count; columPos++)
    {
      tableMessage += nowTable.Cell(rowPos, columPos).Range.Text;
      tableMessage = tableMessage.Remove(tableMessage.Length - 2, 2);
      tableMessage += "\t";
    }
 
    tableMessage += "\n";
  }
 
  MessageBox.Show(tableMessage);
}

相關(guān)文章

最新評(píng)論

尼木县| 巫溪县| 花莲县| 子洲县| 昌平区| 潍坊市| 武穴市| 丰顺县| 西林县| 申扎县| 濮阳市| 南平市| 卫辉市| 新泰市| 莱芜市| 特克斯县| 江源县| 会泽县| 宜宾县| 永州市| 秭归县| 通州市| 汉沽区| 南雄市| 赣榆县| 兴仁县| 新邵县| 乃东县| 兰坪| 建水县| 孟津县| 陇南市| 德安县| 尖扎县| 唐山市| 夏河县| 民和| 永福县| 青川县| 沁源县| 咸丰县|