page 302

Export Data from Listview to XML

2011-08-04 03:01:14 Written by Koohji

Why Export Listview to Office OpenXML?

Office OpenXML has its own advantages. Office OpenXML, or Extensible Markup Language is a set of rules for encoding documents in machine-readable form. The real power of Office OpenXML comes from the fact that with Office OpenXML, not only can you define your own set of tags, but the rules specified by those tags need not be limited to formatting rules. And the most benefit of Office OpenXML is that because you are writing your own markup language, you are not restricted to a limited set of tags defined by proprietary vendors. Furthermore, Office OpenXML allows you to define all sorts of tags with all sorts of rules, such as tags representing business rules or tags representing data description or data relationships.

How to Export Listview to Office OpenXML?

As a professional and powerful .NET component suit for data exporting, Spire.DataExport for .NET can export data from Database to MS Excel,MS Word, HTML, Office OpenXML, PDF, MS Access, DBF, SQL Script, SYLK, DIF, CSV ,MS Clipboard format and of course enable to export ListView to Office OpenXML.

Spire.DataExport for .NET offers an easy solution on Exporting listview to Office OpenXML. Download Spire.DataExport (or Spire.Office) with .NET framework 2.0 (or above) together and use the code below to Export Listview to Office OpenXML:

[C#]
this.xmlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
			this.xmlExport1.DataFormats.CultureName = "zh-CN";
			this.xmlExport1.DataFormats.Currency = "c";
			this.xmlExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
			this.xmlExport1.DataFormats.Float = "g";
			this.xmlExport1.DataFormats.Integer = "g";
			this.xmlExport1.DataFormats.Time = "H:mm";
			this.xmlExport1.FileName = "sample.xml";
            this.xmlExport1.DataSource = Common.ExportSource.ListView;
            this.xmlExport1.ListView = this.listView1;
oleDbConnection1.Open();
try{
xmlExport1.SaveToFile();
}
Finally
{
oleDbConnection1.Close();

}
[VB.NET]
Me.xmlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
            Me.xmlExport1.DataFormats.CultureName = "zh-CN"
            Me.xmlExport1.DataFormats.Currency = "c"
            Me.xmlExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
            Me.xmlExport1.DataFormats.Float = "g"
            Me.xmlExport1.DataFormats.Integer = "g"
            Me.xmlExport1.DataFormats.Time = "H:mm"
            Me.xmlExport1.FileName = "sample.xml"
            Me.xmlExport1.DataSource = Common.ExportSource.ListView
            Me.xmlExport1.ListView = Me.listView1
oleDbConnection1.Open()
            Try
                 xmlExport1.SaveToFile()
Finally
                Me.oleDbConnection1.Close()
            End Try

Export Data from Listview to RTF

2011-08-04 02:53:36 Written by Koohji

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()

Export Data from Listview to HTML

2011-08-03 03:55:07 Written by Koohji

Spire.DataExport for .NET, is a professional .NET component suit for data exporting. It allows programmers export data from database to MS Excel, MS Word, HTML, XML, PDF, MS Access, DBF, SQL Script, SYLK, DIF, CSV ,MS Clipboard format. Here we will introduce how to export data from listview to HTML.

As the predominant markup language for web pages, HTMLwhich stands for HyperText Markup Language is written in the form of HTML elements consisting of tags, enclosed in angle brackets (like ), within the web page content. It's the basic building-blocks of webpages. HTML has many advantages such as:

  • Easy to use
  • Loose syntax (although, being too flexible will not comply with standards)
  • Supported on almost every browser, if not all browsers
  • Free - You need not buy any software
  • Easy to learn & code even for novice programmers
  • Very similar to XML syntax, which is increasingly used for data storage
  • Widely used; established on almost every website, if not all websites

Spire.DataExport presents an easy way to export data from Listview to HTML. Download Spire.DataExport (or Spire.Office) with .NET framework 2.0 (or above) together and use the code below to export data from Listview to HTML with C#/VB.NET.

[C#]
Spire.DataExport.HTML.HTMLExport htmlExport1;
this.htmlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
			this.htmlExport1.DataFormats.CultureName = "zh-CN";
			this.htmlExport1.DataFormats.Currency = "c";
			this.htmlExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
			this.htmlExport1.DataFormats.Float = "g";
			this.htmlExport1.DataFormats.Integer = "g";
			this.htmlExport1.DataFormats.Time = "H:mm";
			this.htmlExport1.FileName = "sample.html";
			this.htmlExport1.HtmlStyle = Spire.DataExport.HTML.HtmlStyle.MSMoney;
			this.htmlExport1.HtmlTableOptions.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(222)), ((System.Byte)(231)), ((System.Byte)(222)));
			this.htmlExport1.HtmlTableOptions.FontColor = System.Drawing.Color.Black;
			this.htmlExport1.HtmlTableOptions.HeadersBackColor = System.Drawing.Color.FromArgb(((System.Byte)(206)), ((System.Byte)(198)), ((System.Byte)(181)));
			this.htmlExport1.HtmlTableOptions.HeadersFontColor = System.Drawing.Color.Black;
			this.htmlExport1.HtmlTableOptions.OddBackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(251)), ((System.Byte)(240)));
			this.htmlExport1.HtmlTextOptions.BackgroundColor = System.Drawing.Color.White;
			this.htmlExport1.HtmlTextOptions.Font = new System.Drawing.Font("Arial", 8F);
			this.htmlExport1.HtmlTextOptions.LinkActiveColor = System.Drawing.Color.Blue;
			this.htmlExport1.HtmlTextOptions.LinkColor = System.Drawing.Color.Red;
			this.htmlExport1.HtmlTextOptions.LinkVisitedColor = System.Drawing.Color.Purple;
            this.htmlExport1.DataSource = Common.ExportSource.ListView;
            this.htmlExport1.ListView = this.listView1;
            htmlExport1.SaveToFile();
[VB.NET]
htmlExport1 As Spire.DataExport.HTML.HTMLExport
            Me.htmlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
            Me.htmlExport1.DataFormats.CultureName = "zh-CN"
            Me.htmlExport1.DataFormats.Currency = "c"
            Me.htmlExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
            Me.htmlExport1.DataFormats.Float = "g"
            Me.htmlExport1.DataFormats.Integer = "g"
            Me.htmlExport1.DataFormats.Time = "H:mm"
            Me.htmlExport1.FileName = "sample.html"
            Me.htmlExport1.HtmlStyle = Spire.DataExport.HTML.HtmlStyle.MSMoney
            Me.htmlExport1.HtmlTableOptions.BackColor = System.Drawing.Color.FromArgb(CType(222, Byte), CType(231, Byte), CType(222, Byte))
            Me.htmlExport1.HtmlTableOptions.FontColor = System.Drawing.Color.Black
            Me.htmlExport1.HtmlTableOptions.HeadersBackColor = System.Drawing.Color.FromArgb(CType(206, Byte), CType(198, Byte), CType(181, Byte))
            Me.htmlExport1.HtmlTableOptions.HeadersFontColor = System.Drawing.Color.Black
            Me.htmlExport1.HtmlTableOptions.OddBackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(251, Byte), CType(240, Byte))
            Me.htmlExport1.HtmlTextOptions.BackgroundColor = System.Drawing.Color.White
            Me.htmlExport1.HtmlTextOptions.Font = New System.Drawing.Font("Arial", 8.0!)
            Me.htmlExport1.HtmlTextOptions.LinkActiveColor = System.Drawing.Color.Blue
            Me.htmlExport1.HtmlTextOptions.LinkColor = System.Drawing.Color.Red
            Me.htmlExport1.HtmlTextOptions.LinkVisitedColor = System.Drawing.Color.Purple
            Me.htmlExport1.DataSource = Common.ExportSource.ListView
            Me.htmlExport1.ListView = Me.listView1
           htmlExport1.SaveToFile()
page 302