We have already demonstrated how to using Spire.XLS hide excel columns and rows in C#. Sometimes we don't want to show the data on a certain cell to others but not hide the whole row or column. Then we can only hide the data on this cell by setting the number format for it. This article will focus on showing how to hide the content on a certain cell by setting the number format as ";;;" to hide the content to others.

Step 1: Initialize an instance of Workbook and load the document from file.

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

Step 2: Get the first worksheet from the workbook.

Worksheet worksheet = workbook.Worksheets[0];

Step 3: Hide the area by setting the number format as ";;;".

worksheet.Range["E2"].NumberFormat = ";;;";

Step 4: Save the document to file.

workbook.SaveToFile("Result.xlsx", FileFormat.Version2010);

Effective screenshot of hide the content on Excel cell by setting the number format:

Hide the content on Cell by setting the number format

Full codes:

using Spire.Xls;
namespace HideContent
{
    class Program
    {

        static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("Sample.xlsx");

            Worksheet worksheet = workbook.Worksheets[0];
            worksheet.Range["E2"].NumberFormat = ";;;";

            workbook.SaveToFile("Result.xlsx", FileFormat.Version2010);
        }
    }
}

Spire.PDF allows us to reset the values of PDF form fields using the PdfResetAction. The following code example demonstrates how we can use Spire.PDF to implement this function.

Code snippet:

Step 1: Create a PDF document and add a new page to it.

PdfDocument document = new PdfDocument();
PdfPageBase page = document.Pages.Add();

Step 2: Create a text box field, set properties for the text box field and add it to the document.

PdfTextBoxField textBoxField = new PdfTextBoxField(page, "Name");
textBoxField.BorderColor = new PdfRGBColor(Color.AliceBlue);
textBoxField.BorderStyle = PdfBorderStyle.Solid;
textBoxField.Bounds = new RectangleF(50, 50, 100, 20);
textBoxField.Text = "Shawn Smith";
document.Form.Fields.Add(textBoxField);

Step 3: Create a button field, set properties for the button field and add it to the document.

PdfButtonField button = new PdfButtonField(page, "Reset");
button.Bounds = new RectangleF(80, 100, 50, 20);
button.BorderColor = new PdfRGBColor(Color.AliceBlue);
button.BorderStyle = PdfBorderStyle.Solid;
button.ToolTip = "Reset";
button.Font = new PdfFont(PdfFontFamily.Helvetica, 9f);
document.Form.Fields.Add(button);

Step 4: Create a reset action for the button field using PdfResetAction class.

PdfResetAction resetAction = new PdfResetAction();
button.Actions.GotFocus = resetAction;

Step 5: Save and close the PDF document.

document.SaveToFile("Output.pdf");
document.Close();

Screenshot before and after resetting value:

Reset the values of PDF form fields in C#

Full code:

using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.Actions;
using Spire.Pdf.Fields;
using Spire.Pdf.Graphics;

namespace Reset_form_fields_in_PDF
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a PDF document
            PdfDocument document = new PdfDocument();

            //Add a new page
            PdfPageBase page = document.Pages.Add();

            //Create a text box field.
            PdfTextBoxField textBoxField = new PdfTextBoxField(page, "Name");

            //Set properties for the text box field.
            textBoxField.BorderColor = new PdfRGBColor(Color.AliceBlue);
            textBoxField.BorderStyle = PdfBorderStyle.Solid;
            textBoxField.Bounds = new RectangleF(50, 50, 100, 20);
            textBoxField.Text = "Shawn Smith";

            //Add the text box field to the document
            document.Form.Fields.Add(textBoxField);

            //Create a button field.
            PdfButtonField button = new PdfButtonField(page, "Reset");
             
            //Set properties for the button field
            button.Bounds = new RectangleF(80, 100, 50, 20);
            button.BorderColor = new PdfRGBColor(Color.AliceBlue);
            button.BorderStyle = PdfBorderStyle.Solid;
            button.ToolTip = "Reset";
            button.Font = new PdfFont(PdfFontFamily.Helvetica, 9f);

            //Add the button field to the document
            document.Form.Fields.Add(button);

            //Create a reset action for the button field
            PdfResetAction resetAction = new PdfResetAction();
            button.Actions.GotFocus = resetAction;

            //Save and close the PDF document
            document.SaveToFile("Output.pdf");
            document.Close();
        }
    }
}

RTF is a document language used for encoding formatted text and graphics for easy transfer between applications. This article presents how to insert a piece of RTF encoded string to Word document using Spire.Doc.

Step 1: Initialize an instance of Document class, add a section to it.

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

Step 2: Add a paragraph to the section.

Paragraph para = section.AddParagraph();

Step 3: Declare a String variable to store the RTF string.

String rtfString = @"{\rtf1\ansi\deff0 {\fonttbl {\f0 hakuyoxingshu7000;}}\f0\fs28 Hello, World}";

Step 4: Append RTF string to paragraph.

para.AppendRTF(rtfString);

Step 5: Save the file.

doc.SaveToFile("Output.docx");

Output:

How to Insert RTF String to Word Documents in C#, VB.NET

Full Code:

[C#]
using Spire.Doc;
using Spire.Doc.Documents;
using System;
namespace InsertRTF
{
 class Program
    {

     static void Main(string[] args)
     {
         Document doc = new Document();
         Section section = doc.AddSection();
         Paragraph para = section.AddParagraph();

         String rtfString = @"{\rtf1\ansi\deff0 {\fonttbl {\f0 hakuyoxingshu7000;}}\f0\fs28 Hello, World}";
         para.AppendRTF(rtfString);

         doc.SaveToFile("Output.docx");

     }

    }
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Documents
Namespace InsertRTF
	Class Program

		Private Shared Sub Main(args As String())
			Dim doc As New Document()
			Dim section As Section = doc.AddSection()
			Dim para As Paragraph = section.AddParagraph()

			Dim rtfString As [String] = "{\rtf1\ansi\deff0 {\fonttbl {\f0 hakuyoxingshu7000;}}\f0\fs28 Hello, World}"
			para.AppendRTF(rtfString)

			doc.SaveToFile("Output.docx")

		End Sub

	End Class
End Namespace
page 204