Click to See Complete Forum and Search --> : Export to Excel


anuradha_th
December 22nd, 2006, 06:10 AM
Hi Friends
I am exporting numeric value(for example 345) to excel.But the value in excel is like this '345.
This converst it into string but I want it to be exported as number. I am not using any third party products to export. Any ideas?

Regards
Anuradha

Shuja Ali
December 22nd, 2006, 06:27 AM
Can you show us the code which you are using. It should not convert a number into a string on its own unless there is formatting being done.

anuradha_th
December 22nd, 2006, 06:47 AM
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filecreated + ";Extended Properties=\"Excel 8.0;HDR=YES;\"";
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");

using (DbConnection connection = factory.CreateConnection())
{
connection.ConnectionString = connectionString;
using (DbCommand command = connection.CreateCommand())
{

string commandtxt;

commandtxt = "INSERT INTO [KEYSALESCURR] ([Dealer Name],[Dealer ID],[Repeat_CSalesNo],[Repeat_CSales]) VALUES ('" + Keyent.DealerName + "'," + Keyent.dealerId + "," + Keyent.Val_RepeatSalesNO + "," + Keyent.Val_RepeatSalesRevenue + ")";

command.CommandText = commandtxt;
connection.Open();
command.ExecuteNonQuery();

connection.Close();
}