Retrieving table data from a doc file using c#

末鹿安然 提交于 2019-12-06 14:06:00

You can use the property Tables of the Document interface to get a collection with all the tables in your document. For each Table in this collection you can get the rows and for each row the cells.

I.e. if app is your Application object you can write something like this to get the text contained in each cell(supposing that there is exactly one in your doc):

    string aCellText;
    foreach (Row aRow in Application.ActiveDocument.Tables[0].Rows)
        foreach (Cell aCell in aRow.Cells)
            aCellText = aCell.Range.Text;

That is not possible with the word, but if you want something like that than you should put tabular data in you excel file and than you can easily read it in the dataset object....

this is not possible to get the data in dataset object from .doc or .docx file. But if your data is in tabular form and also in the excel sheet than you can retrieve the data in dataset object. MS Word is for documentation purpose and excel is used for maintaining data sheets..

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!