如何从excel模板生成excel图表 [英] how to generate excel chart from excel template

查看:106
本文介绍了如何从excel模板生成excel图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1。我在excel表中有10列数据



2.我创建了一个包含2列(工资,平均值)的excel模板和由这两列生成的图表



3.我需要将Excel模板作为输入,输出应该是



一个excel带有2列DATA的工作表和由该数据生成的CHART或GRAPH



neds紧急帮助...... thnx

解决方案

您好,如果您打算使用Excel模板文件作为应用程序的输入,请尝试 .net excel 库。

您可以轻松完成所需的任务:

- 加载模板文件,

- 将新数据插入模板文件,

- 保存文件。



请参阅以下 C#excel 示例代码:

 ExcelFile ef = ExcelFile.Load(  ChartTemplate.xlsx); 
ExcelWorksheet ws = ef.Worksheets [ 0 ];

Random rnd = new Random();

// 将一些数据添加到薪资和平均列
for int i = 0 ; i < 10 ; i ++)
{
ws.Cells [i + < span class =code-digit> 1 , 0 ]。值= rnd.Next( 1000 5000 );
ws.Cells [i + 1 1 ]。值= 3000 ;
}

ef.Save( Charts.xlsx );



VB.NET excel 示例:

  Dim  ef  As  ExcelFile = ExcelFile.Load (  ChartTemplate.xlsx
Dim ws 作为 ExcelWorksheet = ef.Worksheets( 0

Dim rnd As Random()

' 将一些数据添加到薪资和平均列
对于 i 作为 整数 = 0 9
ws.Cells(i + 1 0 )。值= rnd。[下一步]( 1000 5000
ws.Cells(i + 1 1 )。值= 3000
下一步

ef.Save( Charts.xlsx


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

解决方案

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")


这篇关于如何从excel模板生成excel图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆