Click here to Skip to main content
14,607,162 members
Rate this:
Please Sign up or sign in to vote.
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
Comments
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?

1 solution

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

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:
- load template file,
- 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")
   

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




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