12,076,216 members (35,767 online)
Rate this:
See more:
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

Rate this:

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[^]
Member 9958867 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 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

Top Experts
Last 24hrsThis month
 Richard MacCutchan 449 OriginalGriff 347 Jochen Arndt 235 F-ES Sitecore 195 Sergey Alexandrovich Kryukov 151
 Dave Kreskowiak 2,836 OriginalGriff 2,805 Richard MacCutchan 2,174 CPallini 1,607 CHill60 1,379