DBFExport.DefaultFloatDecimal question

Technical support for Spire.DataExport

Moderators: iceblue support, DataExport, Manager

DBFExport.DefaultFloatDecimal question

Postby gacanepa » Thu Jul 28, 2011 6:36 pm

I was wondering if after loading an Excel file there is a way to export it to .dbf with one or two columns with DBFExport.DefaultFloatDecimal=3 and another column with DBFExport.DefaultFloatDecimal=0.
Also, I've read in this forum that Spire.DataExport doesn't work with Excel 2007, but I have been able to read .xls files and .xlsx as well. So, I guess it works after all! Congratulations on this fantastic component!
Keep up the good work!
gacanepa
 
Posts: 8
Joined: Thu Jul 21, 2011 2:59 pm

Re: DBFExport.DefaultFloatDecimal question

Postby Justin Weng » Fri Jul 29, 2011 3:26 am

Dear gacanepa,
Thanks for your inquiry.
#1 About export dbf with one or two columns, it's sorry to say that we can not support this.
#2 Our Spire.DataExport just support export excel 2003 or earlier. You said "Read" xls or xlsx what do you mean?
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar
Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Re: DBFExport.DefaultFloatDecimal question

Postby gacanepa » Fri Jul 29, 2011 12:51 pm

Justin Weng wrote:Dear gacanepa,
Thanks for your inquiry.
#1 About export dbf with one or two columns, it's sorry to say that we can not support this.
#2 Our Spire.DataExport just support export excel 2003 or earlier. You said "Read" xls or xlsx what do you mean?


Dear Justin,
About #2, I mean that, using Spire.DataExport, I was able to load a .xlsx file into a datagrid and then export it to .dbf.
About #1, in this datagrid there are 6 columns and 3 of them hold numerical data. Let's call these last 3: Column A, Column B and Column C. I have noticed that if DBFExport.DefaultFloatDecimal is not used, the numerical data in the .dbf file is exported with a default of 4 decimal places. I am trying to find a workaround to use DBFExport.DefaultFloatDecimal=3 in Column A and B but DBFExport.DefaultFloatDecimal=0 in Column C. But if this is not supported, it's OK. I am very thankful for your component.
gacanepa
 
Posts: 8
Joined: Thu Jul 21, 2011 2:59 pm

Re: DBFExport.DefaultFloatDecimal question

Postby Justin Weng » Mon Aug 01, 2011 2:59 am

Dear gacanepa,
Thanks for your inquiry and supporting our product.
We will be the study of your problem.
It's interesting that how did you load your .xlsx file.
Would you like upload a demo/code to me, I'll be appreciated.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar
Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Re: DBFExport.DefaultFloatDecimal question

Postby gacanepa » Mon Aug 01, 2011 11:56 am

Justin Weng wrote:Dear gacanepa,
Thanks for your inquiry and supporting our product.
We will be the study of your problem.
It's interesting that how did you load your .xlsx file.
Would you like upload a demo/code to me, I'll be appreciated.

Justin,
Here's what's inside the click event of the button that is used to browse for .xls or .xlsx files:
Code: Select all
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "Excel 2003/2007 files|*.xls;*.xlsx";
                DialogResult dlgResult = dlg.ShowDialog();
                if (dlgResult == DialogResult.OK)
                {
                    txtPath.Text = dlg.FileName; // txtPath is a text box that will show the file's location
                }

Next, there is a "Load file" button with the following code inside its click event:
Code: Select all
            if (System.IO.File.Exists(txtPath.Text))
            {
                string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", txtPath.Text);
                string query = String.Format("select * from [{0}$]", "Sheet2"); //it loads the data found in Sheet2, but you can set it to any sheet you want
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);
                DataSet dataset = new DataSet();
                dataAdapter.Fill(dataset);
                dataGridView1.DataSource = dataset.Tables[0];
            }

Then it exports the file:
Code: Select all
                Spire.DataExport.DBF.DBFExport DBFExport = new Spire.DataExport.DBF.DBFExport();
                DBFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
                DBFExport.DataTable = this.dataGridView1.DataSource as DataTable;
                dataGridView1.Columns[2].DefaultCellStyle.Format = "0.00";
                DBFExport.DefaultFloatDecimal = 3;
                DBFExport.ExportIfEmpty = true;
                DBFExport.AutoFitColWidth = true;
                DBFExport.FileName = "C:\\Documents and Settings\\...\\whatever.dbf";
                try
                   {
                      DBFExport.SaveToFile();
                      MessageBox.Show("Success.", "Notice: ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   }
                 catch
                   {
                      MessageBox.Show("Fail", "Warning: ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                   }
            }

It works like a charm! I hope you will find my experience useful, as I have found your component.
I'm still trying to find a workaround so that I can export some columns with 3 decimal figures and others with none. Let me know if you find out anything. Thanks!
gacanepa
 
Posts: 8
Joined: Thu Jul 21, 2011 2:59 pm

Re: DBFExport.DefaultFloatDecimal question

Postby Justin Weng » Mon Aug 01, 2011 2:30 pm

Dear gacanepa,
Thanks for your inquiry and your solution.
It is awsome. We'll try to add that feature to Spire.DataExport, too.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar
Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Re: DBFExport.DefaultFloatDecimal question

Postby gacanepa » Mon Aug 01, 2011 5:37 pm

Justin Weng wrote:Dear gacanepa,
Thanks for your inquiry and your solution.
It is awsome. We'll try to add that feature to Spire.DataExport, too.

No problem. I'm glad I was able to contribute something, considering I found your component to be VERY useful. I look forward to hearing from you. Feel free to drop me a line at my registration email if you want to.
Congrats on your excellent job.
gacanepa
 
Posts: 8
Joined: Thu Jul 21, 2011 2:59 pm

Re: DBFExport.DefaultFloatDecimal question

Postby Justin Weng » Wed Aug 03, 2011 3:53 am

Dear gacanepa,
Thanks for your inquiry.
I maybe found a solution to set each column float decimal. And I got what you want.
Add BeforeExportRow Event.
And the code like this.
Code: Select all
 private void dbfExport1_BeforeExportRow(object sender, EventArgs.ExportRowEventArgs e)
        {
            foreach (var item in e.RowExport.Index.Keys)
            {
                if (item.ToString() == "Column Name")
                {
                    e.RowExport.ColumnsExport.OwnerFormatsExport.Float = "#,###,##0.0000";
                }
            }
        }
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar
Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Re: DBFExport.DefaultFloatDecimal question

Postby tdloc » Wed Aug 03, 2011 8:41 am

Hi,

This component is very useful.

Please help me to export Unicode text to DBF?

And I see this:
Maximum field name length

10 characters for traditional Xbase DBFs. 128 characters for Visual FoxPro (VFP) tables associated with a data dictionary.


Does DBFExport support this "128 characters for Visual FoxPro (VFP) tables associated with a data dictionary" ?

Thanks.

Edited.
tdloc
 
Posts: 5
Joined: Wed Aug 03, 2011 3:19 am

Re: DBFExport.DefaultFloatDecimal question

Postby Justin Weng » Thu Aug 04, 2011 2:12 am

Dear tdloc,
Thanks for your inquiry.
I think you misunderstand our component.
Spire.DataExport can export data from DataTable, ListView and SQL Command.
Please have a check. http://www.e-iceblue.com/Introduce/data-export-for-net-intro.html
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar
Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Re: DBFExport.DefaultFloatDecimal question

Postby tdloc » Thu Aug 04, 2011 2:56 am

Justin Weng wrote:Dear tdloc,
Thanks for your inquiry.
I think you misunderstand our component.
Spire.DataExport can export data from DataTable, ListView and SQL Command.
Please have a check. http://www.e-iceblue.com/Introduce/data-export-for-net-intro.html


Hi Justin Weng,

I used this component to Export data from DataGridView (contain unicode character) to DBF file.
And in the output DBF my field name is cut at 10 character (the field name in DataGridView is longer than 10 character), and the unicode text is broken.

Please help me to fix this.

One more question, how to make progress bar when export file.

Thanks for your reply.
tdloc
 
Posts: 5
Joined: Wed Aug 03, 2011 3:19 am


Return to Spire.DataExport

Who is online

Users browsing this forum: No registered users and 0 guests