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:
c# asp.net powerpoint document viewer: ASP.NET PowerPoint Document Viewer Control: view pptx files online in C# using ASP.NET
c# asp.net dicom document viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
c# asp.net tiff document viewer: ASP.NET Tiff Document Viewer: view, annotate Tiff files in HTML using C# Control
asp.net dotnetnuke pdf editor using c#: ASP.NET DNN PDF Editor Control: view, edit PDF files in Dotnetnuke application
asp.net pdf editor using c#: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
asp.net annotate pdf using c#: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
asp.net convert pdf using c#: ASP.NET Convert PDF Control: Convert, export PDF to Word, HTML, Tiff files in 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(@"");