Click here to Skip to main content
15,903,175 members
Home / Discussions / C#
   

C#

 
QuestionAnyone know how to programmatically change the datatype on a column in an Excel worksheet? Pin
Alaric_11-Nov-11 7:22
professionalAlaric_11-Nov-11 7:22 
AnswerRe: Anyone know how to programmatically change the datatype on a column in an Excel worksheet? Pin
Wayne Gaylard11-Nov-11 7:33
professionalWayne Gaylard11-Nov-11 7:33 
GeneralRe: Anyone know how to programmatically change the datatype on a column in an Excel worksheet? Pin
Alaric_11-Nov-11 8:12
professionalAlaric_11-Nov-11 8:12 
GeneralRe: Anyone know how to programmatically change the datatype on a column in an Excel worksheet? Pin
Wayne Gaylard11-Nov-11 8:26
professionalWayne Gaylard11-Nov-11 8:26 
GeneralRe: Anyone know how to programmatically change the datatype on a column in an Excel worksheet? Pin
Alaric_11-Nov-11 8:31
professionalAlaric_11-Nov-11 8:31 
GeneralRe: Anyone know how to programmatically change the datatype on a column in an Excel worksheet? Pin
Alaric_11-Nov-11 8:40
professionalAlaric_11-Nov-11 8:40 
GeneralRe: Anyone know how to programmatically change the datatype on a column in an Excel worksheet? Pin
Wayne Gaylard11-Nov-11 8:49
professionalWayne Gaylard11-Nov-11 8:49 
GeneralRe: Anyone know how to programmatically change the datatype on a column in an Excel worksheet? Pin
Alaric_11-Nov-11 10:40
professionalAlaric_11-Nov-11 10:40 
Ok...another mental block:

I can read the rows in the sheet, I can access the cells from the row via an OleDbDataReader

...but how do I hook directly into a row in the Excel spreadsheet to update it once I have my update record crafted?
C#
using (OleDbCommand command = connection.CreateCommand())
{
   int idx = 0;
   command.CommandText = string.Format("select * from [{0}$]", "Report_12251104");
   using (OleDbDataReader reader = command.ExecuteReader())
   {
       while (reader.Read())
       {
          string foo = reader[0].ToString();
          string newcolumn = foo.Substring(foo.IndexOf(":") + 1);
                            
          object[] meta = new object[reader.FieldCount];
          reader.GetValues(meta);
          List<object> list = meta.ToList();
          list.Insert(2,newcolumn);
       }
       OleDbCommand update = connection.CreateCommand();
       //I want 
       update.CommandText = "update ??what exactly?? Can I use idx to id a row by number??";
       update.ExecuteNonQuery();
       idx++;
    }
}

"I need build Skynet. Plz send code"

QuestionArgumentException Pin
si_6911-Nov-11 5:39
si_6911-Nov-11 5:39 
AnswerRe: ArgumentException Pin
SledgeHammer0111-Nov-11 7:09
SledgeHammer0111-Nov-11 7:09 
GeneralRe: ArgumentException Pin
AspDotNetDev11-Nov-11 7:34
protectorAspDotNetDev11-Nov-11 7:34 
GeneralRe: ArgumentException Pin
SledgeHammer0111-Nov-11 7:47
SledgeHammer0111-Nov-11 7:47 
GeneralRe: ArgumentException Pin
AspDotNetDev11-Nov-11 7:53
protectorAspDotNetDev11-Nov-11 7:53 
AnswerRe: ArgumentException Pin
Not Active11-Nov-11 7:31
mentorNot Active11-Nov-11 7:31 
AnswerRe: ArgumentException Pin
Ennis Ray Lynch, Jr.11-Nov-11 8:49
Ennis Ray Lynch, Jr.11-Nov-11 8:49 
AnswerRe: ArgumentException Pin
jschell11-Nov-11 12:37
jschell11-Nov-11 12:37 
QuestionWorking with MP3 Files Pin
adigi10-Nov-11 23:53
adigi10-Nov-11 23:53 
AnswerRe: Working with MP3 Files Pin
Wayne Gaylard11-Nov-11 0:04
professionalWayne Gaylard11-Nov-11 0:04 
GeneralRe: Working with MP3 Files Pin
adigi11-Nov-11 0:55
adigi11-Nov-11 0:55 
AnswerRe: Working with MP3 Files Pin
Ravi Bhavnani11-Nov-11 10:16
professionalRavi Bhavnani11-Nov-11 10:16 
AnswerRe: Working with MP3 Files Pin
BillWoodruff11-Nov-11 15:58
professionalBillWoodruff11-Nov-11 15:58 
QuestionCannot using generic type in extension method Pin
Tran Hai Quan10-Nov-11 22:05
Tran Hai Quan10-Nov-11 22:05 
AnswerRe: Cannot using generic type in extension method PinPopular
Wayne Gaylard10-Nov-11 22:41
professionalWayne Gaylard10-Nov-11 22:41 
GeneralRe: Cannot using generic type in extension method Pin
Tran Hai Quan10-Nov-11 22:47
Tran Hai Quan10-Nov-11 22:47 
AnswerRe: Cannot using generic type in extension method Pin
BillWoodruff11-Nov-11 5:49
professionalBillWoodruff11-Nov-11 5:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.