Finalize or call gc after using Excel-obj?


#1

Hi, problem:

Use aspose.excel to read from excel files. Files are loaded when user clicks button on winform. First time this happens, everything goes alright. I debug some stuff, and press "Stop Debuggin" in Visual Studio 2003. I hit run again (F5), but this time the excel files are mis-read when I try to read them.

Errors like:

**************************************

An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll

Additional information: Cast from string "Lsl1z6F7" to type 'Double' is not valid.
***************************************

(the value in the file is something like 34.48)

The files are the same as before, the data valus are the same, but it seems like old vesions of aspose.execel are "hanging around" in memory and f****s things up or something similar. If I leave the machine and go for coffee, and wait, say 10 minutes, the problem seems to dissapear.

Question:

A) Do I need to call finalize, gc or similar after using aspose.excel.excel object ?

B) Do I need to call close or similar to Excel object ?

C) Do I need to set a Aspose.Excel.Excel-object to Nothing after using it ? (like ADODB.Connections)

D) Do I need to close a Worksheet object after reading it ??

thx

Toke


#2

Dear Toke,

You don't need to call finalize, gc or similar methods for Aspose.Excel is a pure dotnet we leave .NET to handle memory allocation.

And you don't need to call close method for any objects. However, to facilitate .NET gc to free memory, setting Excel object to null when you don't need it is a good practice.

Do you use an evaluation copy? In evaluation copy, Aspose.Excel will randomly inject a garbage text in a cell in each worksheet after reading files. It's an evaluation limiation. Please check http://www.aspose.com/wiki/default.aspx/Aspose.Excel/LicensingComponent.html for more information.

When Aspose.Excel is licensed, all will be fine. If you cannot make the purchase decision and you want to make further investigation, you can request a 30 day evaluation license to our sales team. Please post your request at http://www.aspose.com/community/Forums/220/ShowForum.aspx .


#3

Just to be sure I understand it correctly:

My datafiles are made in "normal excel" .

I open them via aspose.excel.excel, and _read_ (not write) some cell value - and when done reading aspose.excel.excel inserts garbage into the cells ???

A) Does this garbage get written back to my files ? (hope not).

B) And, if I declare a new aspose.excel.excel object, reload the same file and read again, should't these changes be resetted ??? (not 'cause I'm trying to work around the copy protection, but because I prefer to understand why I have weird exceptions getting thrown all over the place currently).

Anyways, thanx for the prompt answer - will go for an evaluation license to see whether it solves the problem.

:)

toke


#4

A) Yes. It will be written into result file.

B) Yes. Garbage text is randomly inserted into a cell. For example, it may be inserted into Cell A1 this time and inserted into Cell B10 next time. Only one cell will be changed.

If licensed, garbage text will be removed.