Redian新闻
>
请教一个问题: 关于excel的
avatar
请教一个问题: 关于excel的# DotNet - 窗口里的风景
c*a
1
想要做到这样: 在一个sheet里面放原始数据, 相当于一张原始表, 在其他几个
sheet里面, 每个sheet产生一张图表,都是采用原始数据中的一些数据,比如,可能
是group by type,可能是 group by date, 也可能是两个sub query的join。
然后,一旦做好那些分析图表, 就不去动那些图表的sheet了, 每次只要更新原始数
据sheet,那些基于原始数据的分析图表,自然就更新了。
我没玩过excel,这样能做到吗? 关键是每次数据更新以后, 不需要去修改分析图
表sheet里面的任何东西了。他们自动就跟着原始数据的更新而更新。
有例子的话能提供一下link吗
谢谢!
avatar
w*7
2
LZ 可以参考这个网站 http://archive.msdn.microsoft.com/mschart
上面有aps.net和winForm的sample, 其中有如何“binging to Excel Files"
for example:
using System.Web.UI.DataVisualization.Charting;
using System.Data;
using System.Data.OleDb;
...
private void Page_Load(object sender, System.EventArgs e)
{
// resolve the address to the Excel file
string fileNameString = this.MapPath(".");
fileNameString += "..\\..\\..\\data\\ExcelData.xls";
// Create connection object by using the preceding connection string.
string sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
fileNameString + ";Extended Properties=\"Excel 8.0;HDR=YES\"";
OleDbConnection myConnection = new OleDbConnection( sConn );
myConnection.Open();
// The code to follow uses a SQL SELECT command to display the data from
the worksheet.
// Create new OleDbCommand to return data from worksheet.
OleDbCommand myCommand = new OleDbCommand( "Select * From [data1$A1:E25]
", myConnection );
// create a database reader
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.
CloseConnection);
// Populate the chart with data in the file
Chart1.DataBindTable(myReader, "HOUR");
// close the reader and the connection
myReader.Close();
myConnection.Close();
}
...
avatar
c*a
3
多谢!
可是excel本身难道没这样的操作功能实现吗? 我是说,不用编程实现,就用excel自
己的那些操作来实现?

【在 w*******7 的大作中提到】
: LZ 可以参考这个网站 http://archive.msdn.microsoft.com/mschart
: 上面有aps.net和winForm的sample, 其中有如何“binging to Excel Files"
: for example:
: using System.Web.UI.DataVisualization.Charting;
: using System.Data;
: using System.Data.OleDb;
: ...
: private void Page_Load(object sender, System.EventArgs e)
: {
: // resolve the address to the Excel file

avatar
S*k
4
It is doable. I have no on-line sample for it, but I did a similar project.
For example, you may use Name Manager to name a column in the data sheet.
Then use the name as the data source of other sheets. The data sheet could
be updated by some code similar to the sample code in wagner167's post.
avatar
n*m
5

excel里的pivottable和pivotchart就是做这个的。你的原始数据可以放在一个sheet里
,也可以储存在别的database里。数据更新后refresh一下就好了

★ 发自iPhone App: ChineseWeb 7.8

【在 c******a 的大作中提到】
: 多谢!
: 可是excel本身难道没这样的操作功能实现吗? 我是说,不用编程实现,就用excel自
: 己的那些操作来实现?

avatar
c*a
6
想要做到这样: 在一个sheet里面放原始数据, 相当于一张原始表, 在其他几个
sheet里面, 每个sheet产生一张图表,都是采用原始数据中的一些数据,比如,可能
是group by type,可能是 group by date, 也可能是两个sub query的join。
然后,一旦做好那些分析图表, 就不去动那些图表的sheet了, 每次只要更新原始数
据sheet,那些基于原始数据的分析图表,自然就更新了。
我没玩过excel,这样能做到吗? 关键是每次数据更新以后, 不需要去修改分析图
表sheet里面的任何东西了。他们自动就跟着原始数据的更新而更新。
有例子的话能提供一下link吗
谢谢!
avatar
w*7
7
LZ 可以参考这个网站 http://archive.msdn.microsoft.com/mschart
上面有aps.net和winForm的sample, 其中有如何“binging to Excel Files"
for example:
using System.Web.UI.DataVisualization.Charting;
using System.Data;
using System.Data.OleDb;
...
private void Page_Load(object sender, System.EventArgs e)
{
// resolve the address to the Excel file
string fileNameString = this.MapPath(".");
fileNameString += "..\\..\\..\\data\\ExcelData.xls";
// Create connection object by using the preceding connection string.
string sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
fileNameString + ";Extended Properties=\"Excel 8.0;HDR=YES\"";
OleDbConnection myConnection = new OleDbConnection( sConn );
myConnection.Open();
// The code to follow uses a SQL SELECT command to display the data from
the worksheet.
// Create new OleDbCommand to return data from worksheet.
OleDbCommand myCommand = new OleDbCommand( "Select * From [data1$A1:E25]
", myConnection );
// create a database reader
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.
CloseConnection);
// Populate the chart with data in the file
Chart1.DataBindTable(myReader, "HOUR");
// close the reader and the connection
myReader.Close();
myConnection.Close();
}
...
avatar
c*a
8
多谢!
可是excel本身难道没这样的操作功能实现吗? 我是说,不用编程实现,就用excel自
己的那些操作来实现?

【在 w*******7 的大作中提到】
: LZ 可以参考这个网站 http://archive.msdn.microsoft.com/mschart
: 上面有aps.net和winForm的sample, 其中有如何“binging to Excel Files"
: for example:
: using System.Web.UI.DataVisualization.Charting;
: using System.Data;
: using System.Data.OleDb;
: ...
: private void Page_Load(object sender, System.EventArgs e)
: {
: // resolve the address to the Excel file

avatar
S*k
9
It is doable. I have no on-line sample for it, but I did a similar project.
For example, you may use Name Manager to name a column in the data sheet.
Then use the name as the data source of other sheets. The data sheet could
be updated by some code similar to the sample code in wagner167's post.
avatar
n*m
10

excel里的pivottable和pivotchart就是做这个的。你的原始数据可以放在一个sheet里
,也可以储存在别的database里。数据更新后refresh一下就好了

★ 发自iPhone App: ChineseWeb 7.8

【在 c******a 的大作中提到】
: 多谢!
: 可是excel本身难道没这样的操作功能实现吗? 我是说,不用编程实现,就用excel自
: 己的那些操作来实现?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。