C#: Online Guide
How To: Word SDK
Table Processing
Table Processing
  |  
Home ›› XDoc.Word ›› C# Word: Process Table

C# Word - Table Processing in C#.NET


Provide C# Users with Variety of  Methods to Setup and Modify Table in Word Document




Overview



With C#.NET Word document table processing Interface control (XDoc.Word).//More TODO, users can also process table in Word document.


Related .net document control helps:
asp.net annotate pdf control: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
powerpoint viewer asp.net mvc: ASP.NET PowerPoint Document Viewer Control (MVC & WebForms): view ppt, pptx files online in C# using ASP.NET
asp.net pdf viewer control: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
document viewer asp.net c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
asp.net edit pdf image control: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net edit pdf text color: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET




C# DLLs: Word Table Processing



Add references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.XDoc.Word.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.Word;




Create Table in Word



The following demo code will show you how to create a table in body only. You can create table in other story as the same way.




String docFilePath = @"";
//Open the document
DOCXDocument document =DOCXDocument.Open(docFilePath);
//Get the main document
IDocument doc = document.GetDocument();
//Create a table with 3 columns and 3 rows for document
ITable table = doc.CreateTable();
//Save the document
doc.Save(@"");





Properties Setup in Table



In C# class programming, you can use specific APIs to process table in Word document, such as setting and modifying properties in table. Please refer to following sample code.




String docFilePath = @"";

//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main ducument
IDocument doc = document.GetDocument();
//Document clone
IDocument doc0 = doc.Clone();
//Create a tablefor document
ITable table = doc0.CreateTable(3,3);
//Table properties
//Cell margin
table.SetCellTopMargin(200);
//Table indent
table.SetTblIndent(500);
//Table alignment
table.SetTableAlignment(TableAlignment.Right);
//Shadow
table.SetShadowFillColor(false, Color.Red);
//Save the document
doc0.Save(@"");





Create, Add and Delete Table Row in Word



A table must contains one row at least, if you want to create a new row or delete an existing one, you can use our APIs in class ITable, and the following demo code show you finish this work.




String docFilePath = @"";
//Open the document
DOCXDocument document = DOCXDocument.Open(docFilePath);
//Get the main ducument
IDocument doc = document.GetDocument();
//Document clone
IDocument doc0 = doc.Clone();
//Create a tablefor document
ITable table = doc0.CreateTable(3, 3);
//Create a row with 3 cells for table
ITableRow row = table.CreateRow(3);

//Save the document
doc0.Save(@"");