控件中国网现已改版,您看到的是老版本网站的镜像,系统正在为您跳转到新网站首页,请稍候.......
中国最专业的商业控件资讯网产品咨询电话:023-67870900 023-67871946
产品咨询EMAIL:SALES@COMPONENTCN.COM

Aspose.Cells实现数据过滤

作者:ComponentCN 出处:ComponentCN 2014年08月12日 阅读:

Aspose.Cells实现数据过滤

Aspose.Cells全面支持Microsoft Excel的数据过滤功能,下面的代码将阐述如何使用Aspose.Cells实现数据过滤功能:
//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream("C:\\book1.xls", FileMode.Open);

//Instantiating a Workbook object
//Opening the Excel file through the file stream
Workbook workbook = new Workbook(fstream);

//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

//Creating AutoFilter by giving the cells range of the heading row
worksheet.AutoFilter.Range = "A1:B1";

//Saving the modified Excel file
workbook.Save("C:\\output.xls");

//Closing the file stream to free all resources
fstream.Close();
 
VB.NET
'Creating a file stream containing the Excel file to be opened
Dim fstream As FileStream = New FileStream("C:\\book1.xls", FileMode.Open)

'Instantiating a Workbook object
'Opening the Excel file through the file stream
Dim workbook As Workbook = New Workbook(fstream)

'Accessing the first worksheet in the Excel file
Dim worksheet As Worksheet = workbook.Worksheets(0)

'Creating AutoFilter by giving the cells range of the heading row
worksheet.AutoFilter.Range = "A1:B1"

'Saving the modified Excel file
workbook.Save("C:\\output.xls")

'Closing the file stream to free all resources
fstream.Close()

另外要实现过滤列,开发者可以调用 AutoFilter class' Filter的方法
C#
//Creating AutoFilter by giving the cells range of the heading row
worksheet.AutoFilter.Range = "A1:B1";

//Filtering columns with specified values
worksheet.AutoFilter.Filter(1, "Bananas");
 

VB.NET
'Creating AutoFilter by giving the cells range of the heading row
Worksheet.AutoFilter.Range = "A1:B1"

'Filtering columns with specified values
Worksheet.AutoFilter.Filter(1, "Bananas")
 

热推产品

  • ActiveReport... 强大的.NET报表设计、浏览、打印、转换控件,可以同时用于WindowsForms谀坔攀戀Forms平台下......
  • AnyChart AnyChart使你可以创建出绚丽的交互式的Flash和HTML5的图表和仪表控件。可以用于仪表盘的创......
首页 | 新闻中心 | 产品中心 | 技术文档 | 友情连接 | 关于磐岩 | 技术支持中心 | 联系我们 | 帮助中心 Copyright-2006 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 电话:023 - 67870900 传真:023 - 67870270 产品咨询:sales@componentcn.com 渝ICP备12000264号 法律顾问:元炳律师事务所 重庆市江北区塔坪36号维丰创意绿苑A座28-5 邮编:400020
在线客服
在线客服系统
在线客服
在线客服系统