Knowledgebase (2311)
Children categories
Adding column(s) in Word is a way to set page layout, which separates the whole document or selected sections into two or more columns. You can also set the column width and the spacing between columns to have the satisfied layout. This article is aimed at introducing how to add a column to Word in WPF using Spire.Doc for WPF.
Create a new project by choosing WPF Application in Visual Studio, add a button in MainWindow. Add Spire.Doc.Wpf.dll as reference to your project, then double click the button to write code.
Step 1: Initialize a new instance of Document class and load a sample Word file.
Document document = new Document();
document.LoadFromFile("sample.docx");
Step 2: Add a column to section one, set the two parameters in AddColumn() method, which stand for the width of columns and the spacing between columns.
document.Sections[0].AddColumn(200f, 20f);
Step 3: Save and launch the file.
document.SaveToFile("result.docx");
System.Diagnostics.Process.Start("result.docx");
Output:

Entire Code:
using Spire.Doc;
using System.Windows;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
Document document = new Document();
document.LoadFromFile("sample.docx");
document.Sections[0].AddColumn(200f, 20f);
document.SaveToFile("result.docx");
System.Diagnostics.Process.Start("result.docx");
}
}
}
Borders can make the associative perception of a table stronger, but sometimes, especially in PowerPoint, you may want to remove them in order to achieve a better visual effect. In this part, we're going to introduce how to set and remove border of an existing table in PowerPoint by using Spire.Presentation for .NET.
Before start, please download and install Spire.Presentation correctly, after that add the Spire.Presentation.dll file as the reference of your project.
Detail steps overview:
Set table border:
Step 1: Create a new presentation instance and load the sample document from file.
Presentation presentation = new Presentation();
presentation.LoadFromFile("testTable.pptx");
Step 2: Find the table by looping through all the slides, and then set borders for it. Users can set different border styles according to their requirements.
foreach (ISlide slide in presentation.Slides)
{
foreach (IShape shape in slide.Shapes)
{
if (shape is ITable)
{
foreach (TableRow row in (shape as ITable).TableRows)
{
foreach (Cell cell in row)
{
cell.BorderTop.FillType = FillFormatType.Solid;
cell.BorderBottom.FillType = FillFormatType.Solid;
cell.BorderLeft.FillType = FillFormatType.Solid;
cell.BorderRight.FillType = FillFormatType.Solid;
}
}
}
}
}
Step 3: Save the file as Border.pptx.
presentation.SaveToFile("Border.pptx", FileFormat.Pptx2010);
Remove table border:
Remove table border is very simple, refer to the following codes:
cell.BorderTop.FillType = FillFormatType.None; cell.BorderBottom.FillType = FillFormatType.None; cell.BorderLeft.FillType = FillFormatType.None; cell.BorderRight.FillType = FillFormatType.None;
Effective screenshots:
Before:

After:

Full codes:
using Spire.Presentation;
using Spire.Presentation.Drawing;
namespace Set_and_Remove_Table_Border_in_PPT
{
class Program
{
static void Main(string[] args)
{
Presentation presentation = new Presentation();
presentation.LoadFromFile("testTable.pptx");
foreach (ISlide slide in presentation.Slides)
{
foreach (IShape shape in slide.Shapes)
{
if (shape is ITable)
{
foreach (TableRow row in (shape as ITable).TableRows)
{
foreach (Cell cell in row)
{
//Add top border and set its FillType as Solid.
cell.BorderTop.FillType = FillFormatType.Solid;
//Remove top border
//cell.BorderTop.FillType = FillFormatType.None;
cell.BorderBottom.FillType = FillFormatType.Solid;
//cell.BorderBottom.FillType = FillFormatType.None;
cell.BorderLeft.FillType = FillFormatType.Solid;
//cell.BorderLeft.FillType = FillFormatType.None;
cell.BorderRight.FillType = FillFormatType.Solid;
//cell.BorderRight.FillType = FillFormatType.None;
}
}
}
}
}
presentation.SaveToFile("Border.pptx", FileFormat.Pptx2010);
}
}
}
PDF and Word are the two most commonly used files in our daily life, however, sometimes we need to do conversion between them due to their own advantages, disadvantages or our different requirements. Spire.Doc for WPF as a professional word component enables developers to convert Word to PDF easily by invoking the document.SaveToFile() method.
This is the screenshot of the original word document:

Now follow the steps below:
First, please download and install Spire.Doc correctly, then create a WPF application project and add the Spire.Doc.Wpf.dll as the reference of your project.
Second, drag a button to the MainWindow, double click the button to add following codes to convert Word to PDF.
//Load document
Document document = new Document();
document.LoadFromFile("sample.docx");
//convert to PDF
document.SaveToFile("toPDF.PDF",FileFormat.PDF);
//Launch the file
System.Diagnostics.Process.Start("toPDF.PDF");
'Load document
Dim document As New Document()
document.LoadFromFile("sample.docx")
'convert to PDF
document.SaveToFile("toPDF.PDF",FileFormat.PDF)
'Launch the file
System.Diagnostics.Process.Start("toPDF.PDF")
Effective screenshot:
