How to close workbook in .net.
I am not getting any method for Aspose.cells.Workbook to close the workbook.
Any help would be gratly appreciated.
Well, Aspose.Cells for .NET does not necessarily require really to free up the resources for the processes as the component is already optimized to do so automatically. Aspose.Cells is created in managed C# and is a pure .NET component, we do not use un-managed code. When objects are no more useful in the processes, GC would collect and release the memory occupied by the objects. Being a pure .NET component, Aspose.Cells for .NET relies on .NET garbage collector (GC) to allocate and free the memory for the different processes, although you may try to also use GC.Collect() or try Workbook.Dispose() and set Workbook to null in some cases for your need. Moreover, if you are using Stream objects, you need to call Close() and Flush() methods to manually release the resources for the objects when they are not used any longer.
Hope, this helps a bit.
Thanks for your quick response and let me know solution for error mentioned below -
In my api/application i’m getting error “Error: You are using an evaluation copy and have opened files exceeding limitation.”.
This error comes when we have many hits on our api and as per your below response i’m looking for a solution to resolve my error(to close too many opened files).
I tried to save the workbook but it didn’t worked, we are not doing any changes in file(only reading file).
I tried to use Workbook.Dispose()…but getting error that “Workbook doesnot contain a definition for Dispose”.
Setting work book object to null is also not helping to resolve my error.
It looks like you are working in evaluation mode. (using Aspose.Cells APIs without setting a valid license in code). We recommend you to kindly apply for 30 days temporary license so you may get a temporary license to work with the APIs with full capacity or to avoid any such (your mentioned) error in your application, see the document to obtain temporary license for your requirements:
Should you have any further queries or issue, feel free to contact us any time, we will be happy to assist you soon.
I am not opening more than 100 instances for the same file at a moment, so i think no license is required. And i need solution to close old opened files. Please suggest me a workaround for this.
I have tried out below solutions but didn’t passed with them -
For your information, the details I provided in one of previous post is not relevant to your task, it is related to garbage collector for freeing up resources when needed (for GC only), i.e.,
Please create a simple console demo application (runnable), zip the project and post us to show the issue, we will check it soon.
PS. we still recommend you to kindly get and try using temporary license to work with the APIs in full capacity or to avoid any such errors or other limitations. The temp license is totally free that will work for 30 days which is sufficient to evaluate the product.
Your issue is just because you are using an evaluation copy of our component. “100 files” or “100 times” means not the count of concurrent operations, but the workbook instantiation times in the application’s life scope. You can get temporary license as guided above.