Click or drag to resize

XmlSaveOptions Class

Represents options for saving to XML format.
Inheritance Hierarchy
SystemObject
  SautinSoft.DocumentSaveOptions
    SautinSoft.DocumentXmlSaveOptions

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.12.16
Syntax
public sealed class XmlSaveOptions : SaveOptions

The XmlSaveOptions type exposes the following members.

Constructors
 NameDescription
Public methodXmlSaveOptions Initializes a new instance of the XmlSaveOptions class.
Top
Properties
 NameDescription
Public propertyContentType Gets the content-type for XML file format: "application/xml".
(Overrides SaveOptionsContentType)
Public propertyConvertNonTabularDataToSpreadsheet Convert even a textual data to a table. Default value: false.
Public propertyNodeLevel1 Set or get a name for root node. Default value: "document".
Public propertyNodeLevel2 Set or get a name for node with level 2. Default value: "page".
Public propertyNodeLevel3 Set or get a name for node with level 3. Default value: "table".
Public propertyNodeLevel4 Set or get a name for node with level 4. Default value: "row".
Public propertyNodeLevel5 Set or get a name for node with level 5. Default value: "cell".
Public propertyUseRowColSpan Set or get a value indicating of using rowspan and colspan attributes. Default value: true.
Top
Example

See Developer Guide: How to save a document in Xml format

How to save a document in Xml format using C#
using System;
using System.IO;
using SautinSoft.Document;
using SautinSoft.Document.Tables;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get your free 100-day key here:   
            // https://sautinsoft.com/start-for-free/

            SaveToXmlFile();
        }

        /// <summary>
        /// Creates a new document and saves it as Xml file.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/save-document-as-xml-net-csharp-vb.php
        /// </remarks>
        static void SaveToXmlFile()
        {
            DocumentCore dc = new DocumentCore();
            DocumentBuilder db = new DocumentBuilder(dc);

            // Create a new table with preferred width.
            Table table = db.StartTable();
            db.TableFormat.PreferredWidth = new TableWidth(LengthUnitConverter.Convert(5, LengthUnit.Inch, LengthUnit.Point), TableWidthUnit.Point);

            // Specify formatting of cells and alignment.
            db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Green, 1);
            db.CellFormat.VerticalAlignment = VerticalAlignment.Top;
            db.ParagraphFormat.Alignment = HorizontalAlignment.Center;

            // Specify height of rows and write text.
            db.RowFormat.Height = new TableRowHeight(105f, HeightRule.Exact);
            db.InsertCell();
            db.Write("This is Row 1 Cell 1");
            db.InsertCell();
            db.Write("This is Row 1 Cell 2");
            db.InsertCell();
            db.Write("This is Row 1 Cell 3");
            db.EndRow();

            // Specify formatting of cells and alignment.
            db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Black, 1);
            db.CellFormat.VerticalAlignment = VerticalAlignment.Center;
            db.ParagraphFormat.Alignment = HorizontalAlignment.Left;

            // Specify height of rows and write text.
            db.RowFormat.Height = new TableRowHeight(150f, HeightRule.Exact);
            db.InsertCell();
            db.Write("This is Row 2 Cell 1");
            db.InsertCell();
            db.Write("This is Row 2 Cell 2");
            db.InsertCell();
            db.Write("This is Row 2 Cell 3");
            db.EndRow();

            // Specify formatting of cells and alignment.
            db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Orange, 1);
            db.CellFormat.VerticalAlignment = VerticalAlignment.Bottom;
            db.ParagraphFormat.Alignment = HorizontalAlignment.Right;

            // Specify height of rows and write text
            db.RowFormat.Height = new TableRowHeight(125f, HeightRule.Exact);
            db.InsertCell();
            db.Write("This is Row 3 Cell 1");
            db.InsertCell();
            db.Write("This is Row 3 Cell 2");
            db.InsertCell();
            db.Write("This is Row 3 Cell 3");
            db.EndRow();
            db.EndTable();

            // Save our document into XML format.
            string filePath = "Result.xml";
            dc.Save(filePath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
        }
    }
}
How to save a document in Xml format using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document
Imports SautinSoft.Document.Tables

Namespace Example
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            SaveToXmlFile()
        End Sub
                ''' Get your free 100-day key here:   
                ''' https://sautinsoft.com/start-for-free/
        ''' <summary>
        ''' Creates a new document and saves it as Xml file.
        ''' </summary>
        ''' <remarks>
        ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/save-document-as-xml-net-csharp-vb.php
        ''' </remarks>
        Private Shared Sub SaveToXmlFile()
            Dim dc As New DocumentCore()
            Dim db As New DocumentBuilder(dc)

            ' Create a new table with preferred width.
            Dim table As Table = db.StartTable()
            db.TableFormat.PreferredWidth = New TableWidth(LengthUnitConverter.Convert(5, LengthUnit.Inch, LengthUnit.Point), TableWidthUnit.Point)

            ' Specify formatting of cells and alignment.
            db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Green, 1)
            db.CellFormat.VerticalAlignment = VerticalAlignment.Top
            db.ParagraphFormat.Alignment = HorizontalAlignment.Center

            ' Specify height of rows and write text.
            db.RowFormat.Height = New TableRowHeight(105F, HeightRule.Exact)
            db.InsertCell()
            db.Write("This is Row 1 Cell 1")
            db.InsertCell()
            db.Write("This is Row 1 Cell 2")
            db.InsertCell()
            db.Write("This is Row 1 Cell 3")
            db.EndRow()

            ' Specify formatting of cells and alignment.
            db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Black, 1)
            db.CellFormat.VerticalAlignment = VerticalAlignment.Center
            db.ParagraphFormat.Alignment = HorizontalAlignment.Left

            ' Specify height of rows and write text.
            db.RowFormat.Height = New TableRowHeight(150F, HeightRule.Exact)
            db.InsertCell()
            db.Write("This is Row 2 Cell 1")
            db.InsertCell()
            db.Write("This is Row 2 Cell 2")
            db.InsertCell()
            db.Write("This is Row 2 Cell 3")
            db.EndRow()

            ' Specify formatting of cells and alignment.
            db.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Orange, 1)
            db.CellFormat.VerticalAlignment = VerticalAlignment.Bottom
            db.ParagraphFormat.Alignment = HorizontalAlignment.Right

            ' Specify height of rows and write text
            db.RowFormat.Height = New TableRowHeight(125F, HeightRule.Exact)
            db.InsertCell()
            db.Write("This is Row 3 Cell 1")
            db.InsertCell()
            db.Write("This is Row 3 Cell 2")
            db.InsertCell()
            db.Write("This is Row 3 Cell 3")
            db.EndRow()
            db.EndTable()

            ' Save our document into XML format.
            Dim filePath As String = "Result.xml"
            dc.Save(filePath)

            ' Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
        End Sub
    End Class
End Namespace
See Also