由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - 请教一个问题: 关于excel的
相关主题
winform显示excel文件的问题Winform Question.Please help.
[转载] 看来确实不能从程序里去删Excel Record那个Control可以做这个事情?
请教:如何在VB程序中显示原封不动的excel worksheet (转载)File.Copy怎么老是出错?
我不知道.net里大家什么用得做多webbrowser control question
Windows, freeBSD, Mac OS X support CLIWhat is SmartClient?
screebshot: winform based weather appHow to cancel DateTimePicker event?
About memory usage of .Net program[合集] 我不知道.net里大家什么用得做多
About mono[合集] webbrowser control question
相关话题的讨论汇总
话题: excel话题: data话题: sheet
进入DotNet版参与讨论
1 (共1页)
c******a
发帖数: 2516
1
想要做到这样: 在一个sheet里面放原始数据, 相当于一张原始表, 在其他几个
sheet里面, 每个sheet产生一张图表,都是采用原始数据中的一些数据,比如,可能
是group by type,可能是 group by date, 也可能是两个sub query的join。
然后,一旦做好那些分析图表, 就不去动那些图表的sheet了, 每次只要更新原始数
据sheet,那些基于原始数据的分析图表,自然就更新了。
我没玩过excel,这样能做到吗? 关键是每次数据更新以后, 不需要去修改分析图
表sheet里面的任何东西了。他们自动就跟着原始数据的更新而更新。
有例子的话能提供一下link吗
谢谢!
w*******7
发帖数: 188
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();
}
...
c******a
发帖数: 2516
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

S***k
发帖数: 370
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.
n*****m
发帖数: 9872
5

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

★ 发自iPhone App: ChineseWeb 7.8

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

c******a
发帖数: 2516
6
想要做到这样: 在一个sheet里面放原始数据, 相当于一张原始表, 在其他几个
sheet里面, 每个sheet产生一张图表,都是采用原始数据中的一些数据,比如,可能
是group by type,可能是 group by date, 也可能是两个sub query的join。
然后,一旦做好那些分析图表, 就不去动那些图表的sheet了, 每次只要更新原始数
据sheet,那些基于原始数据的分析图表,自然就更新了。
我没玩过excel,这样能做到吗? 关键是每次数据更新以后, 不需要去修改分析图
表sheet里面的任何东西了。他们自动就跟着原始数据的更新而更新。
有例子的话能提供一下link吗
谢谢!
w*******7
发帖数: 188
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();
}
...
c******a
发帖数: 2516
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

S***k
发帖数: 370
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.
n*****m
发帖数: 9872
10

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

★ 发自iPhone App: ChineseWeb 7.8

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

1 (共1页)
进入DotNet版参与讨论
相关主题
[合集] webbrowser control questionWindows, freeBSD, Mac OS X support CLI
C#的new在method declaration里有和没有有啥区别么screebshot: winform based weather app
Demos from MIX08About memory usage of .Net program
Looking for .Net winform developer with oralce backgroundAbout mono
winform显示excel文件的问题Winform Question.Please help.
[转载] 看来确实不能从程序里去删Excel Record那个Control可以做这个事情?
请教:如何在VB程序中显示原封不动的excel worksheet (转载)File.Copy怎么老是出错?
我不知道.net里大家什么用得做多webbrowser control question
相关话题的讨论汇总
话题: excel话题: data话题: sheet