Export Data from Listview to RTF

Why Export Listview to RTF?

RTF (Rich Text Format) is one of three core file formats which Microsoft supports natively along with DOC and DOCX. It's a cross-platform file extension supported by almost all word processors regardless of operating system. RTF word processing files are typically smaller, safer and can be used across a variety of operating systems. Main advantages of RTF:

  • File Transparency
  • The ability mentioned above of RTF files to be read by the receiver regardless of the type of word processor or its version or the operating system being used. While in some cases this may be the most essential requirement.
  • No Risk of Viruses
  • Unlike Word .doc files, RTF files cannot contain the numerous "macro" and other viruses that plague Microsoft Word documents. Many business and other e-mail servers refuse to accept e-mailed "attachments" which are in .doc format because of all the viruses that may be carried by Word .doc files. However, they will accept the same document in RTF, since the RTF file cannot transmit viruses. This security against the risk of virus infection applies regardless of whether your document would be conveyed via diskette, e-mail attachment, or as an archived web file.
  • Smaller File Size for Text Documents
  • For having greater disk storage capacity, this may sometimes be an advantage.

How to Export Listview to RTF?

Spire.DataExport for .NET as a professional .NET component suit for data exporting can easily help to export Listview to RTF. Download Spire.DataExport (or Spire.Office) with .NET framework 2.0 (or above) together and use the code below to Export Listview to RTF:

[C#]
this.rtfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
			this.rtfExport1.DataFormats.CultureName = "en-us";
			this.rtfExport1.DataFormats.Currency = "c";
			this.rtfExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
			this.rtfExport1.DataFormats.Float = "g";
			this.rtfExport1.DataFormats.Integer = "g";
			this.rtfExport1.DataFormats.Time = "H:mm";
			this.rtfExport1.FileName = "sample.doc";
			this.rtfExport1.RTFOptions.DataStyle.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
			this.rtfExport1.RTFOptions.FooterStyle.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
			this.rtfExport1.RTFOptions.HeaderStyle.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
			this.rtfExport1.RTFOptions.TitleStyle.Alignment = Spire.DataExport.RTF.RtfTextAlignment.Center;
			this.rtfExport1.RTFOptions.TitleStyle.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Bold);
                             this.rtfExport1.DataSource = ExportSource.ListView;
                            this.rtfExport1.ListView = this.ListView1
          rtfExport1.SaveToFile();
[VB.NET]
Me.rtfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
            Me.rtfExport1.DataFormats.CultureName = "en-us"
            Me.rtfExport1.DataFormats.Currency = "c"
            Me.rtfExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
            Me.rtfExport1.DataFormats.Float = "g"
            Me.rtfExport1.DataFormats.Integer = "g"
            Me.rtfExport1.DataFormats.Time = "H:mm"
            Me.rtfExport1.FileName = "sample.doc"
            Me.rtfExport1.RTFOptions.DataStyle.Font = New System.Drawing.Font("Arial", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World)
            Me.rtfExport1.RTFOptions.FooterStyle.Font = New System.Drawing.Font("Arial", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World)
            Me.rtfExport1.RTFOptions.HeaderStyle.Font = New System.Drawing.Font("Arial", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World)
            Me.rtfExport1.RTFOptions.TitleStyle.Alignment = Spire.DataExport.RTF.RtfTextAlignment.Center
            Me.rtfExport1.RTFOptions.TitleStyle.Font = New System.Drawing.Font("Arial", 10.0!, System.Drawing.FontStyle.Bold)
            Me.rtfExport1.DataSource = Common.ExportSource.ListView
            Me.cellExport1.ListView = Me.ListView1
            Me.cellExport1.SaveToFile()