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

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

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

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

object oFileName = @"F:\數(shù)據(jù)庫.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}個表:\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)文章

最新評論

巢湖市| 稻城县| 文山县| 迁安市| 梨树县| 南靖县| 兴仁县| 白玉县| 龙井市| 旬邑县| 辽中县| 黄大仙区| 富川| 剑河县| 武宣县| 金川县| 尼玛县| 汉寿县| 务川| 镇安县| 禄劝| 乡城县| 台中县| 白水县| 汽车| 龙川县| 互助| 霍山县| 紫金县| 元朗区| 青川县| 天水市| 寻甸| 德化县| 河源市| 谷城县| 无极县| 石楼县| 湖北省| 达孜县| 扎囊县|