14,607,162 members
Rate this:
See more:
1. I have data in 10 columns in excel sheet

2. I created an excel template with 2 columns (salary, average) and a graph generated by those 2 columns

3. I need to take that Excel template as input and the out put should be

"An excel sheet with 2 columns of DATA and a CHART or GRAPH generated by that data"

neds urgent help...thnx
Posted
HimanshuJoshi 25-Apr-11 20:05pm

Where exactly seems to be the problem? Or in other words, have you done anything yet?
Bassam Abdul-Baki 6-Jul-11 8:25am

You can easily replace the two column data with each of the five pairs of data to update the chart automatically. Are you looking to do this using a programming language or what? What do you mean by using the template as an input? An input where?

Rate this:

## Solution 2

Hi, if you meant to use Excel template file as an input for your application then try this .net excel library.
You can easily do required tasks:
- insert new data into a template file,
- save file.

See the following C# excel sample code:
```ExcelFile ef = ExcelFile.Load("ChartTemplate.xlsx");
ExcelWorksheet ws = ef.Worksheets[0];

Random rnd = new Random();

//Adding some data to Salary and Average columns
for (int i = 0; i < 10; i++)
{
ws.Cells[i + 1, 0].Value = rnd.Next(1000, 5000);
ws.Cells[i + 1, 1].Value = 3000;
}

ef.Save("Charts.xlsx");```

Or VB.NET excel sample:
```Dim ef As ExcelFile = ExcelFile.Load("ChartTemplate.xlsx")
Dim ws As ExcelWorksheet = ef.Worksheets(0)

Dim rnd As New Random()

'Adding some data to Salary and Average columns
For i As Integer = 0 To 9
ws.Cells(i + 1, 0).Value = rnd.[Next](1000, 5000)
ws.Cells(i + 1, 1).Value = 3000
Next

ef.Save("Charts.xlsx")```