using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Docs.Word; namespace Table_Style { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // Creates a new instance of Document class and reads a .doc file into this structure Document Doc = new Document(); Doc.ReadDoc(@"..\..\Data\WordTable.doc"); // Gets a table Table tTable = (Table)Doc.Sections[0].Nodes[0]; // For every row in this table... for (int i = 0; i < tTable.Rows.Count; i++) { // Writes the count of columns of the row textBox1.Text += "Row " + (i+1) + " - columns count: " + tTable.Rows[i].Cells.Count + "\r\n"; // For every cell in this row... for (int j = 0; j < tTable.Rows[i].Cells.Count; j++) { // Gets the next cell Cell tCell = tTable.Rows[i].Cells[j]; // Writes the properties of the cell if (tCell.Nodes[0].Type == NodeType.Paragraph) textBox1.Text += "Row " + (i+1) + ", Cell " + (j+1) + " - text : " + ((Paragraph)tCell.Nodes[0]).Text + "\r\n"; textBox1.Text += "Row " + (i+1) + ", Cell " + (j+1) + " - width (in twips) : " + tCell.Width + "\r\n"; textBox1.Text += "Row " + (i+1) + ", Cell " + (j+1) + " - position (in twips) : " + tCell.PosX + "\r\n"; textBox1.Text += "Row " + (i+1) + ", Cell " + (j+1) + " - has shading : " + tCell.Shading.HasShading + "\r\n"; textBox1.Text += "\r\n"; } textBox1.Text += "=============================\r\n"; } } } }