Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Export data from listview to excel

4 711 vues

Publié le

Publié dans : Technologie, Design
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Export data from listview to excel

  1. 1. How to Export Data from Listview to Excel with C#/VB.NET<br />Spire.DataExport, as a 100% pure .NET component suit for data exporting from SQL Command, Listview and DataTable into MS Excel,MS Word, HTML, XML, PDF, MS Access, DBF, SQL Script, SYLK, DIF, CSV ,MS Clipboard format, quickly and easily! Here we will introduce how to export data from Listview to Excel with C#/VB.NET.<br />As an electronic spreadsheet program, MS Excel owns a lot of advantages such as it can be used for storing, organizing and manipulating data. Over several decades, Microsoft has updated, expanded and tweaked Excel to keep up with both modern technology and the needs of spreadsheet users. MS Excel has been the most popular data organizing program. So we may usually need export data from database into Excel, such as from ListView. <br />How to Export Data from Listview to Excel with C#/VB.NET?<br />Spire.DataExport presents an easy way to export data from Listview to Excel. And it offers both C# and VB.Net language to realize it. <br />Download Spire.DataExport (or Spire.Office) with .NET framework together and use the code below to export data from Listview to Excel with C#/VB.NET.<br />C# Listview to Excel<br />this.cellExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;<br />this.cellExport1.AutoFitColWidth = true;<br /> this.cellExport1.DataFormats.CultureName = "en-us";<br />this.cellExport1.DataFormats.Currency = "?#,###,##0.00";<br />this.cellExport1.DataFormats.DateTime = "yyyy-M-d H:mm";<br />this.cellExport1.DataFormats.Float = "#,###,##0.00";<br />this.cellExport1.DataFormats.Integer = "#,###,##0";<br />this.cellExport1.DataFormats.Time = "H:mm";<br />this.cellExport1.FileName = "sample.xls";<br />this.cellExport1.SheetOptions.AggregateFormat.Font.Name = "Arial";<br />this.cellExport1.SheetOptions.CustomDataFormat.Font.Name = "Arial";<br />this.cellExport1.SheetOptions.DefaultFont.Name = "Arial";<br />this.cellExport1.SheetOptions.FooterFormat.Font.Name = "Arial";<br />this.cellExport1.SheetOptions.HeaderFormat.Font.Name = "Arial";<br />this.cellExport1.SheetOptions.HyperlinkFormat.Font.Color = Spire.DataExport.XLS.CellColor.Blue;<br />this.cellExport1.SheetOptions.HyperlinkFormat.Font.Name = "Arial";<br />this.cellExport1.SheetOptions.HyperlinkFormat.Font.Underline = Spire.DataExport.XLS.XlsFontUnderline.Single;<br />this.cellExport1.SheetOptions.NoteFormat.Alignment.Horizontal = Spire.DataExport.XLS.HorizontalAlignment.Left;<br />this.cellExport1.SheetOptions.NoteFormat.Alignment.Vertical = Spire.DataExport.XLS.VerticalAlignment.Top;<br />this.cellExport1.SheetOptions.NoteFormat.Font.Bold = true;<br />this.cellExport1.SheetOptions.NoteFormat.Font.Name = "Tahoma";<br />this.cellExport1.SheetOptions.NoteFormat.Font.Size = 8F;<br />this.cellExport1.SheetOptions.TitlesFormat.Font.Bold = true;<br />this.cellExport1.SheetOptions.TitlesFormat.Font.Name = "Arial";<br /> this.cellExport1.DataSource = ExportSource.ListView;<br /> this.cellExport1.ListView = this.ListView1;<br />cellExport1.SaveToFile();<br />ListView to Excel with VB.NET Code<br />VB.NET Listview to Excel:<br />Me.cellExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView<br /> Me.cellExport1.AutoFitColWidth = True<br /> Me.cellExport1.DataFormats.CultureName = "en-us"<br /> Me.cellExport1.DataFormats.Currency = "?#,###,##0.00"<br /> Me.cellExport1.DataFormats.DateTime = "yyyy-M-d H:mm"<br /> Me.cellExport1.DataFormats.Float = "#,###,##0.00"<br /> Me.cellExport1.DataFormats.Integer = "#,###,##0"<br /> Me.cellExport1.DataFormats.Time = "H:mm"<br /> Me.cellExport1.FileName = "sample.xls"<br /> Me.cellExport1.SheetOptions.AggregateFormat.Font.Name = "Arial"<br /> Me.cellExport1.SheetOptions.CustomDataFormat.Font.Name = "Arial"<br /> Me.cellExport1.SheetOptions.DefaultFont.Name = "Arial"<br /> Me.cellExport1.SheetOptions.FooterFormat.Font.Name = "Arial"<br /> Me.cellExport1.SheetOptions.HeaderFormat.Font.Name = "Arial"<br /> Me.cellExport1.SheetOptions.HyperlinkFormat.Font.Color = Spire.DataExport.XLS.CellColor.Blue<br /> Me.cellExport1.SheetOptions.HyperlinkFormat.Font.Name = "Arial"<br /> Me.cellExport1.SheetOptions.HyperlinkFormat.Font.Underline = Spire.DataExport.XLS.XlsFontUnderline.Single<br /> Me.cellExport1.SheetOptions.NoteFormat.Alignment.Horizontal = Spire.DataExport.XLS.HorizontalAlignment.Left<br /> Me.cellExport1.SheetOptions.NoteFormat.Alignment.Vertical = Spire.DataExport.XLS.VerticalAlignment.Top<br /> Me.cellExport1.SheetOptions.NoteFormat.Font.Bold = True<br /> Me.cellExport1.SheetOptions.NoteFormat.Font.Name = "Tahoma"<br /> Me.cellExport1.SheetOptions.NoteFormat.Font.Size = 8.0!<br /> Me.cellExport1.SheetOptions.TitlesFormat.Font.Bold = True<br /> Me.cellExport1.SheetOptions.TitlesFormat.Font.Name = "Arial"<br /> Me.cellExport1.DataSource = Common.ExportSource.ListView<br /> Me.cellExport1.ListView = Me.ListView1<br /> cellExport1.SaveToFile()<br />More about Spire.DataExport<br />Download Spire.DataExport<br />Purchase Spire.DataExport<br />

×