Click here to Skip to main content
15,881,581 members

Loading data from excel in C#

Member 9958867 asked:

Open original thread
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
C#
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
Tags: C# (C# 4.0)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900