For Purchase and
Technical Questions

Here you'll find answers to common questions about E-iceblue's Spire product series, covering both purchase and technical topics, so you can get solutions more efficiently.

Q1: 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

Q2: 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.

Q: How do I add Titles?

A : Add titles with the following code.

pdfExport1.Header.Add("Spire.DataExport Headers");

Q: How do I set the Page Numbers?

A : The Spire.DataExport produces page number automatically, You can't set page number in current version.

Q: How do I add the Column Headers?

A : The Spire.DataExport procedures column headers automatically, according your set datasource.

Q: Page Size (Landscape or Portrait)

A : Set page size with following code.

pdfExport1.PDFOptions.PageOptions.Orientation = Spire.DataExport.Common.PageOrientation.Landscape;

Q: Can I use Microsoft Application Blocks to get the data and then set the DataSource to a DataTable? Currently I am getting an error.

A : If you set the Datasource to a DataTable , You need to set DataTable property to a datatable instance.

Discuss here

Q3: 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

Q4: 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

Q5: 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

Q6: 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

Q7: 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?

The code:

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 library, 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

Q8: Is it possible to set the export to Tab Delimited?

A : Please try to using following source code:

txtExport1.CSVOption.Separator = "\tab";

Discuss here

Q9: 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?

Q: Is it possible to push the savetoHttpResponse to a popup and download the data from there?
Is it possible to save to stream and add the stream in my updatepanel so the download will be activated?

A : We recommend that you can iframe to link a aspx page, so you can use savetoreponse methd to download file.

Discuss here

Q10: 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

Q11: 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

Q12: 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:
1. use OleDbConnection to open the Excel file as a DataSource
2. use Spire.DataExport to export the data to a PDF file.
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

Q13: 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: Data Export PDF for C#, VB.NET.

Discuss here

Q14: 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

Q15: Is it possible to export data from database to Word with images and hyperlinks inserted with the free data export library?

A : The free library 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

Q16: 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

Q17: 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 library supports it. Please check it on: Data Export Bar Chart for C#, VB.NET. Download Data Export library here.

Q18: I learn that you can provide free data export library for downloading. I want to know if this library can export a large amount of data, for example, nearly 16000 columns.

A : There is no column limitation of the free library. But, it will be limited by the file size. What's more, it supports only 65536 columns of Excel 2003.

Discuss here

Q19: 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

Q20: 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

Q21: 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

Q22: 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

Q23: 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

Q24: 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.

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 here. You could buy a license of Spire.DataExport Charged Edition from here.

Discuss here

Q25: 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

Q26: 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