We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem With Filtering Data

Hi,

My requirement is, I have to dump data from month start date to month end date.

While saving the file, I want filter data and show the data for last three days of month.

I mean, when I open the sheet , the data should filtered and shows only last three days data.

Please if any one can provide CODE for this.

Thanks In Advance,

Hi,


I am not sure about your requirement and how could you do this in MS Excel. We also recommend you to please see the document on how to set filters to filter data in an Excel sheet:
http://www.aspose.com/docs/display/cellsnet/Data+Filtering+and+Validation

If you still could not evaluate, kindly create your desired filters in MS Excel manually, save the file and share it here, we will check your issue soon.

Thank you

Hi,

i have attached the sheet for sample data.

In the sheet, the data is there for entire month, but i filtered out for last 3 days of month and saved.

So when you open sheet, you can see only last three days data.

The same functionality , i need to get through C# code.

So, please if any one could help me out.

Thanks in advance.

HI, can any one suggest code for the above post.

Thanks,

Hi,


Thanks for providing us the sample file that contains your desired filtered data set.

We are looking into your desired results for filtered data as per your template Excel file you attached. We may provide you the sample code (via Aspose.Cells APIs) to accomplish your task. A task/ticket is already logged for your issue with an id “CELLSNET-41902” into our database. We will get back to you soon.

Thank you.

Hi,


Please see the following sample code with the attached template file to accomplish your tasks/needs.

Sample code:

Workbook workbook = new Workbook(@“e:\test2\book_base.xlsx”);
AutoFilter filter = workbook.Worksheets[0].AutoFilter;
filter.AddDateFilter(0, DateTimeGroupingType.Day, 2013, 8, 29, 0, 0, 0);
filter.AddDateFilter(0, DateTimeGroupingType.Day, 2013, 8, 30, 0, 0, 0);
filter.AddDateFilter(0, DateTimeGroupingType.Day, 2013, 8, 31, 0, 0, 0);
filter.Refresh();

workbook.Save(@“e:\test2\dest.xlsx”);

Thank you.

Hi,

As per your code, do we need to cretae two excel sheets.

because you are referring one workbook and saving workbook with another name.

If that is the case, it is not my requirement.

I want to do in same workbook.

Please suggest.

Thanks,

Hi,


No, I just gave you the example, you may do what you want. You may save the Excel file with the same name, please use the same filename_with_path in Workbook.Save() method.

Thank you.

Hi,

I tried your code but I am not getting any results.

Could you please provide code for Filtering other than dates.

Thanks in advance,

Hi,


Well, we did provide you the code snippet as per your requirements mentioned in your post (in this thread): https://forum.aspose.com/t/90025

Here is our sample code:
(Please download and use the latest version: Aspose.Cells for .NET 7.5.2 for your needs.)

Sample code:

Workbook workbook = new Workbook(@“e:\test2\book_base.xlsx”);
AutoFilter filter = workbook.Worksheets[0].AutoFilter;
filter.AddDateFilter(0, DateTimeGroupingType.Day, 2013, 8, 29, 0, 0, 0);
filter.AddDateFilter(0, DateTimeGroupingType.Day, 2013, 8, 30, 0, 0, 0);
filter.AddDateFilter(0, DateTimeGroupingType.Day, 2013, 8, 31, 0, 0, 0);
filter.Refresh();

workbook.Save(@“e:\test2\dest.xlsx”);

And, please find attached the input and output file for your reference. For your information, it is same as per your requirement in your template Excel file “Book_sample.xlsx”.


"Could you please provide code for Filtering other than dates."
If you need other requirements, kindly provide more details and do attach another Excel file containing your pivot table with your filtered data set, also provide some screen shots taken in MS Excel to highlight it more. We will check it soon.

Thank you.




The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan