Spire.DataExport
Spire.DataExport (29)
Children categories
1, How to add picture in spreadsheets ?
Q: How to add picture in spreadsheets ?
A: You can add pictures to result excel files with the following code:
CellImage img1 = new CellImage(); img1.Column = 1; img1.PictureName = "demo"; img1.Row = 1; cellExport1.Images.Add(img1); CellPicture pic1= new CellPicture(); pic1.FileName = "C:\\demo.gif"; pic1.Name = "demo"; cellExport1.Pictures.Add(pic1); cellExport1.SaveToFile();
Discuss here
2, Adding Titles
Q: The PDF export tool to me is a cool product. But I have couple of things that I am stuck and the help document is of no help at all. What I am trying to accomplish wit the PDF export is the following:
Answers:
Add titles with the following code.
pdfExport1.Header.Add("Spire.DataExport Headers");
The Spire.DataExport produces page number automatically, You can't set page number in current version
The Spire.DataExport procedures column headers automatically, according your set datasource.
Set page size with following code.
pdfExport1.PDFOptions.PageOptions.Orientation = Spire.DataExport.Common.PageOrientation.Landscape;
If you set the Datasource to a DataTable , You need to set DataTable property to a datatable instance.
Discuss here
3, Restrict Date Format in Excel to 'dd\mm\yy'
Q: While exporting to excel, Is there a way to restrict the format for date columns like 'dd\mm\yy'. And should not allow user to enter any other format on the excel.
A: If you want to set data format on a column, You need to write code in GetDataParams event. Try to use the following example code:
private void cellExport1_GetDataParams(object sender, Spire.DataExport.EventArgs.DataParamsEventArgs e)
{
if (e.Col == 1)
{
e.FormatText = "dd/MM/yy";
}
}
Discuss here
4, Export to PDF
Q: Is there any possibility for export HTML document to PDF?
A: Spire.DataExport can export data into html, excel, PDF document, etc, If you want export HTML document to PDF, you need to parse the html file and export data to PDF by Spire.DataExport.
discuss here
5, DBF column attributes
Q: Looking at the product for possible purchase but have not been able to determine how the change/modify the attributes for a given column. That is we may have rows in which we have an output column that needs a different precison then the column next to it, or we have a string/text output column that has a length/size that is different then the source data.
A: You can set ColumnsPrecision property value to change length and precision of column.
Format: ColumnName=Length,Precision
example: PartNo=8,2
Discuss here
6, export a datalist and a created chart image
Q: One of my collegues gave me your dataexport module to integrate into a project. However i'm not seeing the possibillity to export a datalist and a created image. Is this possible?
A: You can export datalist and a created image to excel file, for more detailed, please see example with installation.
Discuss here
7, export to xls: date not in date format
Q: I'm doing an export to excel but my date is not displayed as a date. the correct date is in there but as a number. If i change the properties of the field, i will get the correct date. How can i fix this?
Spire.DataExport.XLS.CellExport exp = new Spire.DataExport.XLS.CellExport(); exp.DataFormats.CultureName = "nl-NL"; exp.DataFormats.Float = "#,###,##0.00"; [b]exp.DataFormats.DateTime = "dd-MM-yyyy";[/b] exp.DataFormats.Currency = "
A: You need to add getParams event to CellExport component, Try to using following source code,
private void cellExport1_GetDataParams(object sender, Spire.DataExport.EventArgs.DataParamsEventArgs e)
{
if (e.Col == 1)
{
e.FormatText = "YYYY-MM-DD";
}
}
Discuss here
8, export to TXT Tab delimited
Q: Is it possible to set the export to Tab Delimited?
A: Please try to using following source code,
txtExport1.CSVOption.Separator = "\tab";
Discuss here
9, solution for export with Ajax?
Q: I'm getting quite used to working with your product, but one thing i'm still not capable of getting it done. I'm working on a project that is using a huge collection of AJAX and the scriptmanager. Since the scriptmanager doesn't really like the use of Respons, the SaveToHttpResponse is not working. Is there any other solution to create the effect that the user can download the file directly?
A: we recommend that you can iframe to link a aspx page, so you can use savetoreponse methd to download file.
Discuss here
10, Speed Issue
Q: We are thinking about purchasing this control, however we are planning on performing large data dumps into csv files using this control, we are looking at around 100k rows from a data table. Has anyone used this DataExport tool to dump this large of data into a file and if so how was the speed issue, canyou give an approximate time of how long it took?
A: This is related to the performance test machines, spent mainly in the implementation of the writing on the document
Discuss here
11, DataTable, DateTime format in DataExport to XLS
Q: When I try to export a DataTable containing a DateTime field to Excel, it is shown as a number. The number is a correct value when shown as DateTime, but the cell format should be DateTime instead of Default. The DataTable correctly contains the column as DateTime.
Here is a code snippet that reproduces the issue:
SqlCommand cmd = new SqlCommand();
cmd.Connection = new SqlConnection(/* Insert some SQL Server connection string */);
cmd.CommandText = "SELECT CAST('2010-01-01 0:00' AS DATETIME)";
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable table = new DataTable();
da.Fill(table);
CellExport ce = new CellExport();
ce.DataTable = table;
ce.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
ce.SaveToHttpResponse("test.xls", Response);
The resulting Excel sheet contains the following data:
Column1
40179
We consider purchasing Spire.DataExport, but I need to make this work... Please help.
A: Please try to using following way, add GetDataParams event to Spire.DataExport.
private void cellExport1_GetDataParams(object sender, Spire.DataExport.EventArgs.DataParamsEventArgs e)
{
//e.sheet equals sheet index, e.col equals column index.
if ((e.Sheet == 0) && (e.Col == 6))
{
e.FormatText = cellExport1.DataFormats.DateTime;
}
}
Discuss here
12, Convert Excel Files xlsx to pdf
Q: is it possible with your Controls to convert a xlsx files to a pdf with only printing and 128bit security.
A: Yes, you can convert Excel File to PDF just need to do two steps:
The method following is a sample, the Excel file D:\temp\DatatableSample.xls is a test file in my computer.
static void ConvertExcelToPDF()
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString
= @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\temp\DatatableSample.xls;Extended Properties=""Excel 8.0""";
OleDbCommand command = new OleDbCommand();
command.CommandText = "select * from [country$A1:E19]";
command.Connection = conn;
conn.Open();
Spire.DataExport.PDF.PDFExport pdfExport1 = new Spire.DataExport.PDF.PDFExport();
pdfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
pdfExport1.DataFormats.CultureName = "en-US";
pdfExport1.DataFormats.Currency = "c";
pdfExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
pdfExport1.DataFormats.Float = "g";
pdfExport1.DataFormats.Integer = "g";
pdfExport1.DataFormats.Time = "H:mm";
pdfExport1.FileName = Guid.NewGuid() + ".pdf";
pdfExport1.PDFOptions.DataFont.CustomFont = new System.Drawing.Font("Arial", 10F);
pdfExport1.PDFOptions.FooterFont.CustomFont = new System.Drawing.Font("Arial", 10F);
pdfExport1.PDFOptions.HeaderFont.CustomFont = new System.Drawing.Font("Arial", 10F);
pdfExport1.PDFOptions.PageOptions.Format = Spire.DataExport.PDF.PageFormat.User;
pdfExport1.PDFOptions.PageOptions.Height = 11.67;
pdfExport1.PDFOptions.PageOptions.MarginBottom = 0.78;
pdfExport1.PDFOptions.PageOptions.MarginLeft = 1.17;
pdfExport1.PDFOptions.PageOptions.MarginRight = 0.57;
pdfExport1.PDFOptions.PageOptions.MarginTop = 0.78;
pdfExport1.PDFOptions.PageOptions.Width = 10.25;
pdfExport1.PDFOptions.TitleFont.CustomFont = new System.Drawing.Font("Arial", 10F);
pdfExport1.SQLCommand = command;
pdfExport1.SaveToFile();
}
But the Spire.DataExport does not currently support the other 2 requirements 'only printing and 128bit security'.
Discuss here
13, Export data from SQL to PDF
Q: I want to export data to PDF from SQL. will free Spire.DataExport help me to do this?
A: You can export data from database to PDF by using SQL command. You can refer to our demo here: http://www.e-iceblue.com/Knowledgebase/Spire.DataExport/Demos/Demo/Data-Export-PDF-for-C-VB.NET.html
Discuss here
14, PDF export, display problem
Q: I'm using SPIRE EXPORT PDF as I want to generate from a datagridview (VB.NET 2010) a pdf ... I'm doing it through a mysql database as I didn't find a way to do it directly !
so the code below saves the data written in the datagridview to the mysql bdd and then, it does an SQL to PDF with SPIRE export pdf
'PrintDocument1.Print()
Dim oleDbConnection1 = New MySqlConnection()
Dim Server As String = "localhost"
Dim Db As String = "PINF"
Dim User As String = "root"
Dim Pwd As String = ""
oleDbConnection1.ConnectionString = "Server=" & Server & ";" _
& "Uid=" & User & ";" _
& "Pwd=" & Pwd & ";" _
& " Database=" & Db & ";"
Dim oleDbCommand1 As New MySqlCommand
oleDbCommand1.Connection = oleDbConnection1
oleDbConnection1.Open()
For i = 0 To dgv.RowCount - 2
oleDbCommand1.CommandText = "insert into ATL values ('" & dgv(0, i).Value & "', '" & dgv(1, i).Value & "', '" & dgv(2, i).Value & "', '" & dgv(3, i).Value & "', '" & dgv(4, i).Value & "', '" & dgv(5, i).Value & "', '" & dgv(6, i).Value & "')"
oleDbCommand1.ExecuteScalar()
Next
Dim pdfExport1 As New Spire.DataExport.PDF.PDFExport()
pdfExport1.PDFOptions.PageOptions.Orientation = 0
pdfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
pdfExport1.DataFormats.CultureName = "fr-FR"
pdfExport1.DataFormats.Currency = "€"
pdfExport1.DataFormats.DateTime = "d-M-yyyy"
pdfExport1.DataFormats.Float = "g"
pdfExport1.DataFormats.[Integer] = "g"
pdfExport1.DataFormats.Time = "H:mm"
pdfExport1.PDFOptions.HeaderFont.AllowCustomFont = True
pdfExport1.PDFOptions.DataFont.AllowCustomFont = True
pdfExport1.PDFOptions.FooterFont.AllowCustomFont = True
pdfExport1.PDFOptions.TitleFont.AllowCustomFont = True
pdfExport1.AutoFitColWidth = False
pdfExport1.FileName = "sample1.pdf"
pdfExport1.PDFOptions.DataFont.CustomFont = New System.Drawing.Font("Arial", 10.0F)
pdfExport1.PDFOptions.FooterFont.CustomFont = New System.Drawing.Font("Arial", 10.0F)
pdfExport1.PDFOptions.HeaderFont.CustomFont = New System.Drawing.Font("Arial", 10.0F)
pdfExport1.PDFOptions.PageOptions.Format = Spire.DataExport.PDF.PageFormat.User
pdfExport1.PDFOptions.PageOptions.Height = 11.67
pdfExport1.PDFOptions.PageOptions.MarginBottom = 0.78
pdfExport1.PDFOptions.PageOptions.MarginLeft = 1.17
pdfExport1.PDFOptions.PageOptions.MarginRight = 0.57
pdfExport1.PDFOptions.PageOptions.MarginTop = 0.78
pdfExport1.PDFOptions.PageOptions.Width = 20
pdfExport1.PDFOptions.TitleFont.CustomFont = New System.Drawing.Font("Arial", 10.0F)
pdfExport1.PDFOptions.ColSpacing = 0
pdfExport1.PDFOptions.RowSpacing = 2
pdfExport1.PDFOptions.GridLineWidth = 2
oleDbCommand1.CommandText = "select * from ATL"
pdfExport1.Header.Text = "ATL"
'pdfExport1.PDFOptions.TitleFont.CustomFont = New System.Drawing.Font("Arial", 20.0F, FontStyle.Bold)
pdfExport1.SQLCommand = oleDbCommand1
pdfExport1.SaveToFile()
oleDbConnection1.Close()
But in the resulted PDF file .... the display is bad, I mean there are not all columns displayed ... and the columns are too spaced ! I don't know how to reduce the spacing of the columns .. if someone knows ..
A: sorry, dataexport does not support custom column header at present. You could use Spire.Doc, by which you can export you data to a document and convert it to pdf please check here to get more information about spire.doc
Discuss here
15, Word Style Support
Q: Is it possible to export data from database to Word with images and hyperlinks inserted with the free data export component?
A: The free component can support several styles of Excel. Therefore, you can insert images and hyperlinks when exporting data to Word by using it. check it here
Discuss here
16, Export data SQL command
Q: I want to use Spire.DataExport to control the data source with SQL command. How can I realize it?
A: You can use the code:
System.Data.OleDb.OleDbCommand oleDbcommand1 = new System.Data.OleDb.OleDbCommand();
And write SQL command in oleDbcommand1.
Discuss here
17, Export Data to Excel and Generate Chart
Q: I want to generate a chart according to my data after exporting data to Excel? Does the free Spire.DataExport support this?
A: Yes, our free component supports it. Please check it on: http://www.e-iceblue.com/Knowledgebase/Spire.DataExport/Demos/Cell/Data-Export-Bar-Chart-for-C-VB.NET.html Download Data Export Component here
18, Large Data Export
Q: I learn that you can provide free data export component for downloading. I want to know if this component can export a large amount of data, for example, nearly 16000 columns.
A: There is no column limitation of the free component. But, it will be limited by the file size. What's more, it supports only 65536 columns of Excel 2003.
Discuss here
19, DB connection issue
Q: Yesterday, I used Spire.DataExport to export data from database, but I can't connect my database, here I give you my code:
OleDbConnection oleDbConnection = new OleDbConnection(); oleDbConnection.ConnectionString = this.txtCollectionString.Text; System.Data.OleDb.OleDbCommand oleDbCommand = new System.Data.OleDb.OleDbCommand(); oleDbCommand.CommandText = this.txtCommandText.Text;
Can you help me?? Thank you in advance."
A: I have realized your problem. After initializing the oleDbConnection and oleDbCommand, you should connect them with the following code:
oleDbCommand.Connection = oleDbConnection;
Discuss here
20, Fill data table
Q: When I fill my data table with the data source of the DataGridView, it appears an error. I give you the code:
worksheet1.DataTable = this.dataGridView.DataSource;
A: You don't convert the type. You should use the following code:
worksheet1.DataTable = this.dataGridView.DataSource as DataTable;
Discuss here
21, Fill DataGridView with command
Q: I want to assign the data source of the DataGridView with the oleDbCommand, but I failed. The code:
dataGridView.DataSource = oleDbCommand;
A: If you want to do so, you should use a data adapter, it like a intermediary of the command and DataGridView. You may use it with the following code:
OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand); DataTable dt = new DataTable(); da.Fill(dt); dataGridView.DataSource = dt;
Discuss here
22, Worksheet export
Q: When I use Spire.DataExport to export data from a database to a worksheet of XLS, it appears an error. I don't know why. Here is my code:
Spire.DataExport.XLS.WorkSheet worksheet1 = new Spire.DataExport.XLS.WorkSheet(); worksheet1.DataSource = Spire.DataExport.Common.ExportSource.DataTable; worksheet1.DataTable = this.dataGridView.DataSource as DataTable;
A: When I use Spire.DataExport to export data from a database to a worksheet of XLS, it appears an error. I don't know why. Here is my code:
Spire.DataExport.XLS.WorkSheet worksheet1 = new Spire.DataExport.XLS.WorkSheet(); worksheet1.DataSource = Spire.DataExport.Common.ExportSource.DataTable; worksheet1.DataTable = this.dataGridView.DataSource as DataTable;
Discuss here
23, Open file
Q: When I run my form, it will save to a file, but it can't open automatically. So I want it launched automatically. Can you help me??
A: Of cource. You can use the following code to realize it:
cellExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
Discuss here
24, Multiple Sheets (workbooks)
Q: I am using the DataExport and trying to build an XLS (Excel) with multiple workbooks/sheets (some people may call it tabs). I followed the following example from e-iceblue's own website: http://www.e-iceblue.com/Knowledgebase/Spire.DataExport/Demos/Cell/net-data-export-cell-multiple-sheets-demo.html#twoj_fragment1-2
The example works great, if you are going to add a maximum of 3 workbooks. I am in need of having around 6. If I try to add a fourth workbook, I do not get an error but I also don't get the fourth workbook. I was thinking I might have an error in the fourth workbook, so I comment out the 3rd workbook’s code and then I ran it again, the 4th workbook can now be seen (In workbook location #3)! Wow, so the fourth workbook has no errors! I uncommited the code for the 3rd workbook and bammm, the fourth workbook can’t be seen again. Only the first 3 workbooks can be seen.
There must be some sort of limitations on how many workbooks can be added? :?:
A: Sorry for any inconvenience caused by us. It looks like that your program worked on Spire.DataExport Community Edition. The maximum of 3 worksheets is a limitation. We also provide a Charged Edition of Spire.DataExport which can support up to 256 worksheets. You could get more information about the difference between them from the last table ,a href="http://www.e-iceblue.com/Introduce/data-export-for-net-intro.html">here. You could buy a license of Spire.DataExport Charged Edition from http://www.e-iceblue.com/Spire.DataExport.html.
Discuss here
25, SaveSpecificationToFile Exception
Q: when i try to save a export specification to file, it throws an exception "ArgumentOutOfRangeException". My code:
Dim txtExport1 As New Spire.DataExport.TXT.TXTExport()
txtExport1.DataSource = Spire.DataExport.Common.ExportSource.DataTable
txtExport1.DataEncoding = Spire.DataExport.Common.EncodingType.ASCII
txtExport1.ExportType = Spire.DataExport.TXT.TextExportType.CSV
txtExport1.SaveSpecificationToFile("C:\test.txt")
A: You can use this method.
txtExport1.SaveToFile("C:\test.txt");
The SaveSpecificationToFile() method can not work.
Discuss here
26, Error During Install
27, Unreadable content Spire DataExport XLS
Q: i opened the export file and excel show popup "Excel found unreadable content in 'xxxxxxx.xls'. Do you want to recover....."
why that popup show and how to hide it ?
A: We need your code and files. Please upload to us, so that we can reproduce the problem.
Discuss here
Why Export Listview to CSV?
CSV file (Comma Separated Values, sometimes also called Comma Delimited) is a specially formatted plain text file which stores spreadsheet or basic database-style information in a very simple format, with one record on each line, and each field within that record separated by a comma. It is often used to exchange data between disparate applications. CSV has become a pseudo standard throughout the industry, even among non-Microsoft platforms because it is used in Microsoft Excel.
CSV files are often used as a simple way to transfer a large volume of spreadsheet or database information between programs, without worrying about special file types. For example, transferring a home-made address book from Excel into a database program such as Filemaker Pro could be done by exporting the file as a CSV from Excel, then importing that CSV into File maker.
How to Export Listview to CSV?
Spire.DataExport for .NET presents an easy solution for exporting Listvie to CSV. Spire.DataExport is a 100% pure .NET component suit for exporting data into MS Excel, MS Word, HTML, XML, PDF, MS Access, DBF, SQL Script, SYLK, DIF, CSV ,MS Clipboard format. Quickly and easily export data from Command, ListView, DataTable components. Save you much time and money by using Spire.DataExport.
Download Spire.DataExport (or Spire.Office) with .NET framework 2.0 (or above) together and use the code below to Export Listview to CSV:
C# Listview to CSV
[C#]
this.txtExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
this.txtExport1.DataFormats.CultureName = "en-us";
this.txtExport1.DataFormats.Currency = "c";
this.txtExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
this.txtExport1.DataFormats.Float = "g";
this.txtExport1.DataFormats.Integer = "g";
this.txtExport1.DataFormats.Time = "H:mm";
this.txtExport1.DataEncoding = Spire.DataExport.Common.EncodingType.ASCII;
this.txtExport1.DataSource = ExportSource.ListView;
this.txtExport1.ListView = this.ListView1
txtExport1.ExportType = TextExportType.CSV;
txtExport1.FileName = "sample.csv";
txtExport1.SaveToFile();
VB.NET Listview to CSV
[Visual Basic]
Me.txtExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
Me.txtExport1.DataFormats.CultureName = "en-us"
Me.txtExport1.DataFormats.Currency = "c"
Me.txtExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
Me.txtExport1.DataFormats.Float = "g"
Me.txtExport1.DataFormats.Integer = "g"
Me.txtExport1.DataFormats.Time = "H:mm"
Me.txtExport1.DataEncoding = Spire.DataExport.Common.EncodingType.ASCII
Me.txtExport1.DataSource = Common.ExportSource.ListView
Me.txtExport1.ListView = Me.ListView1
txtExport1.ExportType = TextExportType.CSV
txtExport1.FileName = "sample.csv"
txtExport1.SaveToFile()
More about Spire.DataExport
Download Spire.DataExport
Purchase Spire.DataExport
Why Export Listview to XML?
XML has its own advantages. XML, or Extensible Markup Language is a set of rules for encoding documents in machine-readable form. The real power of XML comes from the fact that with XML, 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 XML 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, XML 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 XML?
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, XML, PDF, MS Access, DBF, SQL Script, SYLK, DIF, CSV ,MS Clipboard format and of course enable to export ListView to XML.
Spire.DataExport for .NET offers an easy solution on Exporting listview to XML. Download Spire.DataExport (or Spire.Office) with .NET framework 2.0 (or above) together and use the code below to Export Listview to XML:
C# Listview to XML
[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 Listview to XML
[Visual Basic]
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
More about Spire.DataExport
Download Spire.DataExport
Purchase Spire.DataExport
