We have already demonstrated whether to display the additional information for presentation slides on header and footer area, such as hide or display date and time, the slide number, and the footer with the help of Spire.Presentation. This article will show you how to reset the position of the slide number and the date time in C#. We will also demonstrate how to reset the display format for the date and time from MM/dd/yyyy to yy.MM.yyyy on the presentation slides.

Firstly, view the default position of the date time at the left and the slide number at the right.

How to reset the position of the date time and slide number for the presentation slides

Step 1: Create a presentation document and load the file from disk.

Presentation presentation = new Presentation();
presentation.LoadFromFile("Sample.pptx", FileFormat.Pptx2013);

Step 2: Get the first slide from the sample document.

ISlide slide = presentation.Slides[0];

Step 3: Reset the position of the slide number to the left and date time to the center, and reset the date time display style.

foreach (IShape shapeToMove in slide.Shapes)
{
    if (shapeToMove.Name.Contains("Slide Number Placeholder"))
    {
        shapeToMove.Left =0;                                                  
     }

    else if (shapeToMove.Name.Contains("Date Placeholder"))
    {
        shapeToMove.Left = presentation.SlideSize.Size.Width / 2;
       
        (shapeToMove as IAutoShape).TextFrame.TextRange.Paragraph.Text = DateTime.Now.ToString("dd.MM.yyyy");
        (shapeToMove as IAutoShape).TextFrame.IsCentered = true;
    }
}

Step 4: Save the document to file.

presentation.SaveToFile("Result.pptx", FileFormat.Pptx2013);

Effective screenshot after reset the position and the format for the date time and slide number.

How to reset the position of the date time and slide number for the presentation slides

Full codes of how to reset the position of slide number and date time:

using Spire.Presentation;
using System;
namespace ResetPosition
{

    class Program
    {

        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();

            presentation.LoadFromFile("Sample.pptx", Spire.Presentation.FileFormat.Pptx2013);

            ISlide slide = presentation.Slides[0];

            foreach (IShape shapeToMove in slide.Shapes)
            {
                if (shapeToMove.Name.Contains("Slide Number Placeholder"))
                {
                    shapeToMove.Left = 0;

                }

                else if (shapeToMove.Name.Contains("Date Placeholder"))
                {
                    shapeToMove.Left = presentation.SlideSize.Size.Width / 2;

                    (shapeToMove as IAutoShape).TextFrame.TextRange.Paragraph.Text = DateTime.Now.ToString("dd.MM.yyyy");
                    (shapeToMove as IAutoShape).TextFrame.IsCentered = true;
                }

            }
            presentation.SaveToFile("Result.pptx", Spire.Presentation.FileFormat.Pptx2013);

        }
    }
}

Searching for high or low values in large amounts of data can be cumbersome and error-prone. Fortunately, in Excel, you can apply conditional formatting to quickly highlight a specified number of top or bottom ranked values in a selected cell range. In this article, you will learn how to programmatically highlight top and bottom values in Excel using Spire.XLS for .NET.

Install Spire.XLS for .NET

To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.XLS

Highlight Top and Bottom Values in Excel in C# and VB.NET

Spire.XLS for .NET provides the XlsConditionalFormats.AddTopBottomCondition(TopBottomType topBottomType, int rank) method to specify the top N or bottom N ranked values, and then you can highlight these values with a background color. The following are the detailed steps.

  • Create a Workbook instance.
  • Load a sample Excel document using Workbook.LoadFromFile() method.
  • Get a specified worksheet by its index using Workbook.Worksheets[sheetIndex] property.
  • Add a conditional formatting to the worksheet using Worksheet.ConditionalFormats.Add() method and return an object of XlsConditionalFormats class.
  • Set the cell range where the conditional formatting will be applied using XlsConditionalFormats.AddRange() method.
  • Add a top condition to specify the highest or top N ranked values using XlsConditionalFormats.AddTopBottomCondition(TopBottomType topBottomType, int rank) method. Then highlight the cells that meet the condition with a background color using IConditionalFormat.BackColor property.
  • Add a bottom condition to specify the lowest or bottom N ranked values and highlight the cells that meet the condition with a background color.
  • Save the result document using Workbook.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Xls;
using Spire.Xls.Core;
using Spire.Xls.Core.Spreadsheet.Collections;
using System.Drawing;

namespace HighlightValues
{
    class Program
    {
        static void Main(string[] args)
        {
            {

                //Create a Workbook instance
                Workbook workbook = new Workbook();

                //Load a sample Excel document
                workbook.LoadFromFile("sample.xlsx");

                //Get the first worksheet
                Worksheet sheet = workbook.Worksheets[0];

                //Add a conditional format to the worksheet
                XlsConditionalFormats format = sheet.ConditionalFormats.Add();

                //Set the range where the conditional format will be applied
                format.AddRange(sheet.Range["B2:F7"]);

                //Apply conditional formatting to highlight the highest values
                IConditionalFormat condition1 = format.AddTopBottomCondition(TopBottomType.Top, 1);
                condition1.BackColor = Color.Red;

                //Apply conditional formatting to highlight the bottom two values
                IConditionalFormat condition2 = format.AddTopBottomCondition(TopBottomType.Bottom, 2);
                condition2.BackColor = Color.ForestGreen;

                //Save the result document
                workbook.SaveToFile("TopBottomValues.xlsx", ExcelVersion.Version2013);

            }
        }
    }
}

C#/VB.NET: Highlight Top and Bottom Ranked Values in Excel

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

A cross-reference refers to related information elsewhere in the same document. You can create cross-references to any existing items such as headings, footnotes, bookmarks, captions, and numbered paragraphs. This article will show you how to create a cross-reference to bookmark using Spire.Doc with C# and VB.NET.

Step 1: Create a Document instance.

Document doc = new Document();
Section section = doc.AddSection();

Step 2: Insert a bookmark.

Paragraph paragraph = section.AddParagraph();
paragraph.AppendBookmarkStart("MyBookmark");
paragraph.AppendText("Text inside a bookmark");
paragraph.AppendBookmarkEnd("MyBookmark");

Step 3: Create a cross-reference field, and link it to the bookmark through bookmark name.

Field field = new Field(doc);
field.Type = FieldType.FieldRef;
field.Code = @"REF MyBookmark \p \h";

Step 4: Add a paragraph, and insert the field to the paragraph.

paragraph = section.AddParagraph();
paragraph.AppendText("For more information, see ");
paragraph.ChildObjects.Add(field);

Step 5: Insert a FieldSeparator object to the paragraph, which works as separator in a field.

FieldMark fieldSeparator= new FieldMark(doc, FieldMarkType.FieldSeparator);
paragraph.ChildObjects.Add(fieldSeparator);

Step 6: Set the display text of the cross-reference field.

TextRange tr = new TextRange(doc);
tr.Text = "above";
paragraph.ChildObjects.Add(tr);

Step 7: Insert a FieldEnd object to the paragraph, which is used to mark the end of a field.

FieldMark fieldEnd = new FieldMark(doc, FieldMarkType.FieldEnd);
paragraph.ChildObjects.Add(fieldEnd);

Step 8: Save to file.

doc.SaveToFile("output.docx", FileFormat.Docx2013);

Output:

The cross-reference appears as a link that takes the reader to the referenced item.

Create a Cross-Reference to Bookmark in Word in C#, VB.NET

Full Code:

[C#]
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
namespace CreatCR
{
    class Program
    {
        static void Main(string[] args)
        {
            Document doc = new Document();
            Section section = doc.AddSection();
            //create a bookmark
            Paragraph paragraph = section.AddParagraph();
            paragraph.AppendBookmarkStart("MyBookmark");
            paragraph.AppendText("Text inside a bookmark");
            paragraph.AppendBookmarkEnd("MyBookmark");
            //insert line breaks
            for (int i = 0; i < 4; i++)
            {
                paragraph.AppendBreak(BreakType.LineBreak);
            }
            //create a cross-reference field, and link it to bookmark                    
            Field field = new Field(doc);
            field.Type = FieldType.FieldRef;
            field.Code = @"REF MyBookmark \p \h";
            //insert field to paragraph
            paragraph = section.AddParagraph();
            paragraph.AppendText("For more information, see ");
            paragraph.ChildObjects.Add(field);
            //insert FieldSeparator object
            FieldMark fieldSeparator = new FieldMark(doc, FieldMarkType.FieldSeparator);
            paragraph.ChildObjects.Add(fieldSeparator);
            //set display text of the field
            TextRange tr = new TextRange(doc);
            tr.Text = "above";
            paragraph.ChildObjects.Add(tr);
            //insert FieldEnd object to mark the end of the field
            FieldMark fieldEnd = new FieldMark(doc, FieldMarkType.FieldEnd);
            paragraph.ChildObjects.Add(fieldEnd);
            //save file
            doc.SaveToFile("output.docx", FileFormat.Docx2013);

        }
    }
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields
Namespace CreatCR
	Class Program
		Private Shared Sub Main(args As String())
			Dim doc As New Document()
			Dim section As Section = doc.AddSection()
			'create a bookmark
			Dim paragraph As Paragraph = section.AddParagraph()
			paragraph.AppendBookmarkStart("MyBookmark")
			paragraph.AppendText("Text inside a bookmark")
			paragraph.AppendBookmarkEnd("MyBookmark")
			'insert line breaks
			For i As Integer = 0 To 3
				paragraph.AppendBreak(BreakType.LineBreak)
			Next
			'create a cross-reference field, and link it to bookmark                    
			Dim field As New Field(doc)
			field.Type = FieldType.FieldRef
			field.Code = "REF MyBookmark \p \h"
			'insert field to paragraph
			paragraph = section.AddParagraph()
			paragraph.AppendText("For more information, see ")
			paragraph.ChildObjects.Add(field)
			'insert FieldSeparator object
			Dim fieldSeparator As New FieldMark(doc, FieldMarkType.FieldSeparator)
			paragraph.ChildObjects.Add(fieldSeparator)
			'set display text of the field
			Dim tr As New TextRange(doc)
			tr.Text = "above"
			paragraph.ChildObjects.Add(tr)
			'insert FieldEnd object to mark the end of the field
			Dim fieldEnd As New FieldMark(doc, FieldMarkType.FieldEnd)
			paragraph.ChildObjects.Add(fieldEnd)
			'save file
			doc.SaveToFile("output.docx", FileFormat.Docx2013)

		End Sub
	End Class
End Namespace

Shapes in Excel serve as visual elements that can decorate or optimize worksheets, including objects such as text boxes and images. By inserting shapes, users are able to present data in a more intuitive manner and emphasize vital information, ultimately improving the readability of the spreadsheets. When it becomes necessary to deal with the contents within the shapes independently, you can programmatically extract them from shapes for further processing. In this article, we will show you how to extract text and images from excel shapes by using Spire.XLS for .NET.

Install Spire.XLS for .NET

To begin with, you need to add the DLL files included in the Spire.XLS for.NET package as references in your .NET project. The DLLs files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.XLS

Extract Text from Excel Shapes

Spire.XLS for .NET allows users to extract text from shape object by using IPrstGeomShape.Text property and write it to a new .txt file. The following are detailed steps.

  • Create a Workbook object.
  • Load an Excel file using Workbook.LoadFromFile() method.
  • Get the first worksheet by  Workbook.Worksheets[] property.
  • Get the second shape by Worksheet.PrstGeomShapes[] property.
  • Extract text content from the second shape and save it to the string variable.
  • Create a StringBuilder object and append the extracted text to it.
  • Write the text to a .txt file using File.WriteAllText() method.
  • C#
  • VB.NET
using System.IO;
using System.Text;
using Spire.Xls;
using Spire.Xls.Core;

namespace Extracttext
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Workbook object
            Workbook workbook = new Workbook();

            //Load the Excel file
            workbook.LoadFromFile("sample.xlsx");

            //Get the first worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Get the second shape and extract text from it
            IPrstGeomShape shape1 = sheet.PrstGeomShapes[1];
            string s = shape1.Text;

            //Append the extracted text to StringBuilder object
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(s);

            //Write the text to a .txt file
            File.WriteAllText("ShapeText.txt", sb.ToString());
            workbook.Dispose();
        }
    }
}

C#/VB.NET: Extract Text and Images from Excel Shapes

Extract Images from Excel Shapes

Additionally, Spire.XLS for .NET also supports extracting the image by using IPrstGeomShape.Fill.Picture property and save it to a local folder. The related steps are as follows.

  • Create a Workbook object.
  • Load an Excel file using Workbook.LoadFromFile() method.
  • Get the first worksheet by  Workbook.Worksheets[] property.
  • Get the first shape by Worksheet.PrstGeomShapes[] property.
  • Extract the image from the first shape by its Fill and Picture property.
  • Save the extracted image to a folder by using Image.Save() method.
  • C#
  • VB.NET
using System.Drawing;
using System.Drawing.Imaging;
using Spire.Xls;
using Spire.Xls.Core;

namespace Extractimage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Workbook object
            Workbook workbook = new Workbook();

            //Load the Excel file
            workbook.LoadFromFile("sample.xlsx");

            //Get the first worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Get the first shape and extract the image from it
            IPrstGeomShape shape2 = sheet.PrstGeomShapes[0];
            Image image = shape2.Fill.Picture;

            //Save the extracted image to a folder
            image.Save(@"Image\ShapeImage.png", ImageFormat.Png);
            workbook.Dispose();
        }
    }
}

C#/VB.NET: Extract Text and Images from Excel Shapes

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

With the help of Spire.XLS, we can easily add shapes to the Excel worksheet. This article will demonstrate how to format the shadow of shape on Excel in C#. We can use Spire.XLS to set the color, size, blur, angle, transparency and distance of the shadow for the shape on Excel worksheet.

Set the shadow style when we add new shape to the Excel worksheet:

using Spire.Xls;
using Spire.Xls.Core;
using System.Drawing;
namespace SetShadowStyle
{
    class Program
    {
        static void Main(string[] args)
        {
            //instantiate a Workbook object and get the first worksheet
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];

            //add an ellipse shape
            IPrstGeomShape ellipse = sheet.PrstGeomShapes.AddPrstGeomShape(5, 5, 150, 100, PrstGeomShapeType.Ellipse);

            //set the shadow style for the ellipse
            ellipse.Shadow.Angle = 90;
            ellipse.Shadow.Distance = 10;
            ellipse.Shadow.Size = 150;
            ellipse.Shadow.Color = Color.Gray;
            ellipse.Shadow.Blur = 30;
            ellipse.Shadow.Transparency = 1;
            ellipse.Shadow.HasCustomStyle = true;

            //save the document to file
            workbook.SaveToFile("Shapeshadow.xlsx", FileFormat.Version2010);
        }
    }
}

Effective screenshot after setting the shadow style for the shape on the Excel worksheet:

Set the shadow style for the shape on Excel worksheet in C#

Set the shadow style when we loaded an Excel document with shape:

using Spire.Xls;
using Spire.Xls.Core;
using System.Drawing;
namespace SetShadowStyle
{
    class Program
    {
        static void Main(string[] args)
        {
            //create an instance of workbook and load the document from file
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("Sample.xlsx");

            //get the first worksheet from the sample document
            Worksheet sheet = workbook.Worksheets[0];

            //get the first shape from the worksheet
            IPrstGeomShape shape = sheet.PrstGeomShapes[0];

            //set the shadow style for the shape
            shape.Shadow.Angle = 90;
            shape.Shadow.Distance = 10;
            shape.Shadow.Size = 120;
            shape.Shadow.Color = Color.Yellow;
            shape.Shadow.Blur = 30;
            shape.Shadow.HasCustomStyle = true;

            //save the document to file
            workbook.SaveToFile("ShadowStyle.xlsx", FileFormat.Version2010);

        }
    }
}

Effective screenshot after setting the shadow style for the shape on the Excel worksheet:

Set the shadow style for the shape on Excel worksheet in C#

When you position some text over an image shape, you may want to make the image lighter or transparent so it doesn’t interfere with text. This article will demonstrate how to apply transparency to the image inside of a shape using Spire.Presentation with C# and VB.NET.

Step 1: Create a Presentation instance.

Presentation presentation = new Presentation();

Step 2: Create an Image from the specified file.

string imagePath = "logo.png";
Image image = Image.FromFile(imagePath);

Step 3: Add a shape to the first slide.

float width = image.Width;
float height = image.Height;
RectangleF rect = new RectangleF(50, 50, width, height);
IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rect);
shape.Line.FillType = FillFormatType.None;

Step 4: Fill the shape with image.

shape.Fill.FillType = FillFormatType.Picture;
shape.Fill.PictureFill.Picture.Url = imagePath;
shape.Fill.PictureFill.FillType = PictureFillType.Stretch;

Step 5: Set transparency on the image.

shape.Fill.PictureFill.Picture.Transparency = 50;

Step 6: Save to file.

presentation.SaveToFile("output.pptx", FileFormat.Pptx2013);

Output:

Apply Transparency to Image in PowerPoint in C#, VB.NET

Full Code:

[C#]
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;

namespace ApplyTransparency
{

    class Program
    {

        static void Main(string[] args)
        {
            {
                //create a PowerPoint document
                Presentation presentation = new Presentation();
                string imagePath = "logo.png";
                Image image = Image.FromFile(imagePath);
                float width = image.Width;
                float height = image.Height;
                RectangleF rect = new RectangleF(50, 50, width, height);
                //add a shape
                IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rect);
                shape.Line.FillType = FillFormatType.None;
                //fill shape with image
                shape.Fill.FillType = FillFormatType.Picture;
                shape.Fill.PictureFill.Picture.Url = imagePath;
                shape.Fill.PictureFill.FillType = PictureFillType.Stretch;
                //set transparency on image
                shape.Fill.PictureFill.Picture.Transparency = 50;
                //save file
                presentation.SaveToFile("output.pptx", FileFormat.Pptx2013);
            }
        }

    }
}
[VB.NET]
Imports Spire.Presentation
Imports Spire.Presentation.Drawing
Imports System.Drawing

Namespace ApplyTransparency

	Class Program

		Private Shared Sub Main(args As String())
			If True Then
				'create a PowerPoint document
				Dim presentation As New Presentation()
				Dim imagePath As String = "logo.png"
				Dim image__1 As Image = Image.FromFile(imagePath)
				Dim width As Single = image__1.Width
				Dim height As Single = image__1.Height
				Dim rect As New RectangleF(50, 50, width, height)
				'add a shape
				Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, rect)
				shape.Line.FillType = FillFormatType.None
				'fill shape with image
				shape.Fill.FillType = FillFormatType.Picture
				shape.Fill.PictureFill.Picture.Url = imagePath
				shape.Fill.PictureFill.FillType = PictureFillType.Stretch
				'set transparency on image
				shape.Fill.PictureFill.Picture.Transparency = 50
				'save file
				presentation.SaveToFile("output.pptx", FileFormat.Pptx2013)
			End If
		End Sub

	End Class
End Namespace

Using Excel conditional formatting, we can quickly find and highlight the duplicate and unique values in a selected cell range. In this article, we’re going to show you how to programmatically highlight duplicate and unique values with different colors using Spire.XLS and conditional formatting.

Detail steps:

Step 1: Initialize an object of Workbook class and Load the Excel file.

Workbook workbook = new Workbook();
workbook.LoadFromFile("Input.xlsx");

Step 2: Get the first worksheet.

Worksheet sheet = workbook.Worksheets[0];

Step 3: Use conditional formatting to highlight duplicate values in range "A2:A10" with IndianRed color.

XlsConditionalFormats xcfs1 = sheet.ConditionalFormats.Add();
xcfs1.AddRange(sheet.Range["A2:A10"]);

IConditionalFormat format1 = xcfs1.AddCondition();
format1.FormatType = ConditionalFormatType.DuplicateValues;
format1.BackColor = Color.IndianRed;

Step 4: Use conditional formatting to highlight unique values in range "A2:A10" with Yellow color.

IConditionalFormat format2 = xcfs1.AddCondition();
format2.FormatType = ConditionalFormatType.UniqueValues;
format2.BackColor = Color.Yellow;"

Step 5: Save the file.

workbook.SaveToFile("HighlightDuplicates.xlsx", ExcelVersion.Version2013);

Screenshot:

Highlight Duplicate and Unique Values in Excel Using C#

Full code:

using Spire.Xls;
using Spire.Xls.Core;
using Spire.Xls.Core.Spreadsheet.Collections;
using System.Drawing;

namespace HighlightDuplicateandUniqueValues
{
    class Program
    {
        static void Main(string[] args)
        {
            //Load the Excel file
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("Input.xlsx");

            //Get the first worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Use conditional formatting to highlight duplicate values in range "A2:A10" with IndianRed color
            XlsConditionalFormats xcfs1 = sheet.ConditionalFormats.Add();
            xcfs1.AddRange(sheet.Range["A2:A10"]);

            IConditionalFormat format1 = xcfs1.AddCondition();
            format1.FormatType = ConditionalFormatType.DuplicateValues;
            format1.BackColor = Color.IndianRed;

            //Use conditional formatting to highlight unique values in range "A2:A10" with Yellow color
            IConditionalFormat format2 = xcfs1.AddCondition();
            format2.FormatType = ConditionalFormatType.UniqueValues;
            format2.BackColor = Color.Yellow;

            //Save the file
            workbook.SaveToFile("HighlightDuplicates.xlsx", ExcelVersion.Version2013);

        }
    }
}

We have already demonstrated how to insert footnote to the word document with the help of Spire.Doc. This article we will show you how to set the position and number format for the footnote. The footnote position can be at the bottom of each page or below text. The default number format for the footnote is “1, 2, 3”. The following example shows how to set the position, number format, and the restart rule of footnote by calling the property of Section.FootnoteOptions.

Firstly, view the Footnote options under Microsoft Word and the original sample document file:

How to set the position and number format for word footnote in C#

How to set the position and number format for word footnote in C#

How to set the position and number format for word footnote in C#

Step 1: Create a new instance of Document and load the document from file.

Document doc = new Document();
doc.LoadFromFile("Sample.docx",FileFormat.Docx2013);

Step 2: Get the first section from the document.

Section sec = doc.Sections[0];

Step 3: Set the number format, restart rule and position for the footnote.

sec.FootnoteOptions.NumberFormat = FootnoteNumberFormat.UpperCaseLetter;
sec.FootnoteOptions.RestartRule = FootnoteRestartRule.RestartPage;
sec.FootnoteOptions.Position = FootnotePosition.PrintAtBottomOfPage;

Step 4: Save the document to file.

doc.SaveToFile("Footnoteoptions.docx", FileFormat.Docx2013);

Effective screenshot after setting the formatting for the footnote.

How to set the position and number format for word footnote in C#

How to set the position and number format for word footnote in C#

Full codes of how to set the footnote options:

Document doc = new Document();
doc.LoadFromFile("Sample.docx", FileFormat.Docx2013);

Section sec = doc.Sections[0];

sec.FootnoteOptions.NumberFormat = FootnoteNumberFormat.UpperCaseLetter;
sec.FootnoteOptions.RestartRule = FootnoteRestartRule.RestartPage;
sec.FootnoteOptions.Position = FootnotePosition.PrintAtBottomOfPage;

////Clear all the formatting for the footnote and back to the default opitions
//sec.FootnoteOptions.ClearFormatting();

doc.SaveToFile("Footnoteoptions.docx", FileFormat.Docx2013);

Text watermark and image watermark are two kinds of watermarks in Word document. The text watermark always shows some additional but related information to the word context. While image watermark is used to make the Word document be more attractive. This section will demonstrate how to use Spire.Doc to add text watermark and image watermark to Word document in C#.

Add Image Watermark in C#:

using Spire.Doc;
namespace SetImageWatermark
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                //create a new instance of Document and load the document from file.
                Document doc = new Document();
                doc.LoadFromFile("Sample.docx", FileFormat.Docx2013);

                //create a new instance of the PictureWatermark and load the picture from file.
                PictureWatermark picture = new PictureWatermark();
                picture.Picture = System.Drawing.Image.FromFile("logo.png");

                //set the image watermark scaling and Washout property
                picture.Scaling = 20;
                picture.IsWashout = false;

                //add the picture watermark
                doc.Watermark = picture;

                //save the document to file
                doc.SaveToFile("ImageWatermark.docx", FileFormat.Docx2013);

            }
        }
    }
}

Add text watermark and image watermark to word document in C#

Add Text Watermark in C#::

using Spire.Doc;
using Spire.Doc.Documents;
using System.Drawing;
namespace SetTextWatermark
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                //create a new instance of Document and load the document from file.
                Document doc = new Document();
                doc.LoadFromFile("Sample.docx", FileFormat.Docx2013);

                //create a new instance of the TextWatermark 
                TextWatermark txtWatermark = new TextWatermark();

                //set the text watermark with text string, font, color and layout.
                txtWatermark.Text = "Confidential";
                txtWatermark.FontSize = 45;
                txtWatermark.Color = Color.Green;
                txtWatermark.Layout = WatermarkLayout.Diagonal;

                //add the text watermark
                doc.Watermark = txtWatermark;

                //save the file.
                doc.SaveToFile("TextWatermark.docx", FileFormat.Docx2013);

            }
        }
    }
}

Add text watermark and image watermark to word document in C#

Microsoft Excel provides 10 date options, ranging from yesterday to next month (see below image) to format selected cells based on the current date. Spire.XLS supports all of these options, in this article, we’re going to show you how to conditionally format dates in Excel using Spire.XLS. If you want to highlight cells based on a date in another cell, or create rules for other dates (i.e., more than a month from the current date), you will have to create your own conditional formatting rule based on a formula.

Conditionally Format Dates in Excel with C#

Detail steps:

Step 1: Initialize an object of Workbook class and load the Excel file.

Workbook workbook = new Workbook();
workbook.LoadFromFile("Input.xlsx");

Step 2: Get the first worksheet.

Worksheet sheet = workbook.Worksheets[0];

Step 3: Add a condition to the used range in the worksheet.

XlsConditionalFormats xcfs1 = sheet.ConditionalFormats.Add();
xcfs1.AddRange(sheet.AllocatedRange);

Step 4: Specify the format type of the condition as time period and set the time period as last 7 days.

IConditionalFormat format1 = xcfs1.AddTimePeriodCondition(TimePeriodType.Last7Days);

Step 5:Set the highlight color.

conditionalFormat.BackColor = Color.Orange;

Step 6:Save the file.

workbook.SaveToFile("ConditionallyFormatDates.xlsx", ExcelVersion.Version2013);

Screenshot::

Conditionally Format Dates in Excel with C#

Full Code:

[C#]
using Spire.Xls;
using Spire.Xls.Core;
using Spire.Xls.Core.Spreadsheet.Collections;
using Spire.Xls.Core.Spreadsheet.ConditionalFormatting;
using System.Drawing;

namespace ConditionallyFormatDates
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize an object of Workbook class
            Workbook workbook = new Workbook();

            //Load the Excel file
            workbook.LoadFromFile("Input.xlsx");

            //Get the first worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Highlight cells that contain a date occurring in the last 7 days
            XlsConditionalFormats xcfs1 = sheet.ConditionalFormats.Add();
            xcfs1.AddRange(sheet.AllocatedRange);

            IConditionalFormat conditionalFormat = xcfs1.AddTimePeriodCondition(TimePeriodType.Last7Days);
            conditionalFormat.BackColor = Color.Orange;

            //Save the file
            workbook.SaveToFile("ConditionallyFormatDates.xlsx", ExcelVersion.Version2013);
        }
    }
}
page 20