none
how to extract the table contents RRS feed

  • Question

  • i have a created a table in word programatically using c#. Now i need to extract the values. But when i try to extract the values inside table. i am getting "\r\a" included at the end of the table cell's text.

    i did like

                       int row = q.Tables[1].Rows.Count;
                        int column = q.Tables[1].Columns.Count;
                        string[,] tableContent = new string[row+1, column+1];
                        for (int i = 1; i <= row; i++)
                        {
                            for (int j = 1; j <= column; j++)
                            {
                                tableContent[i, j] = q.Tables[1].Cell(i, j).Range.Text.ToString();
                            }
                        }

    is this a right of extracting table contents or else anyother there to extract table contents?

    thanks in advance.

    Saturday, February 18, 2012 9:22 AM

Answers

  • The extra characters at the end of the string are the cell marker (which you can see in the document if you turn on nonprinting character display with the ¶ button). You have two choices: you can remove the last two characters of the string after getting it the way you're doing now; or you can define a Range object, set it to the range of the cell, and move its end one character to the left (Word treats the cell marker as a single character for this purpose), then get the text of the reduced range.

    Jay Freedman
    MS Word MVP  FAQ: http://word.mvps.org

    • Marked as answer by Shyamaldas Saturday, February 18, 2012 6:29 PM
    Saturday, February 18, 2012 5:02 PM

All replies

  • The extra characters at the end of the string are the cell marker (which you can see in the document if you turn on nonprinting character display with the ¶ button). You have two choices: you can remove the last two characters of the string after getting it the way you're doing now; or you can define a Range object, set it to the range of the cell, and move its end one character to the left (Word treats the cell marker as a single character for this purpose), then get the text of the reduced range.

    Jay Freedman
    MS Word MVP  FAQ: http://word.mvps.org

    • Marked as answer by Shyamaldas Saturday, February 18, 2012 6:29 PM
    Saturday, February 18, 2012 5:02 PM
  • i solved my problem . thank you sir.
    Saturday, February 18, 2012 6:29 PM