Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hello Friends
I want to develop codes in C#. I have an excel file consist of ten rows and three column. I have to develop Random number and I will multiply that random numbers with the each row in excel file.
So, In order to do this:
How I will call excel file and access to the each row and column and then multiply with the random numbers.
To explain this more consider
C = ax + by +z:
where (a, b) are the random numbers (this is also an array of 100 rows and 2 column) generated in the C# and x, y, z is the experimental data saved in excel file. I have to access to the excel file and multiply the first row (a, b) with the first row in excel (x, y , z) to calculate C and similarly through all rows using for or while loop in C#.
How to program this code.
I expect full co-operation from you all.
Thank you very much
Ilyas
 
Edit:
Hello Thanks I have generated Random Like in the codes below
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
 
namespace RandomNumber 
{ 
 
    class Program 
    { 
          static void Main(string[] args) 
          { 
             Double[,] randdouble = new Double[100, 2]; 
             Random randNum = new Random(); 
 
             for (int row = 0; row < randdouble.GetLength(0); row++) 
             { 
                   for (int col = 0; col < randdouble.GetLength(1); col++) 
                   { 
                        Double x = randNum.NextDouble(); 
                        randdouble[row, col] = x; 
                        Console.Write(randdouble[row, col]); 
                        Console.Write(" ");
                   } 
                   Console.WriteLine(); 
             } 
          } 
    } 
}
But how to proceed next is the main hurdle in my codes development. Thanks
Posted 14-Apr-13 19:38pm
Edited 14-Apr-13 20:06pm
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I dont know about your random number, as one could easily solve it by using the Random class.
 
The excel file could be read like the documentation here specifies, where most instances are covered:
http://support.microsoft.com/kb/302084[^]
 
It is advicable to use a array instead though, and I have done this here in VB:
Sound in games - Rooms[^]
  Permalink  
Comments
Member 9958867 at 15-Apr-13 1:00am
   
Hello Thanks
I have generated Random Like in the codes below
sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace RandomNumber
{
class Program
{
static void Main(string[] args)
{
 
Double[,] randdouble = new Double[100, 2];
Random randNum = new Random();
for (int row = 0; row < randdouble.GetLength(0); row++)
{
for (int col = 0; col < randdouble.GetLength(1); col++)
{
Double x = randNum.NextDouble();
 
randdouble[row, col] = x;
 
Console.Write(randdouble[row, col]);
Console.Write(" ");
}
Console.WriteLine();
}
}
}
}
 
But how to proceed next is the main hurdle in my codes development.
Thanks
Member 9958867 at 15-Apr-13 1:27am
   
Hello Kenneth Haugland
Thanks for your response, but I want to read each rows and column of Excel . The subject codes which you have sent is writing in Excel.
Thank you very much for your co-operation
Ilyas

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 410
1 Jochen Arndt 200
2 Richard MacCutchan 135
3 DamithSL 105
4 PIEBALDconsult 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 15 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100