Free Support Forum -

Error on Excel upload


We are reading a very data intensive Excel file and recieve an error on certain conditions.

Here is a simple example with a test.xls file (has to be xls).

Dim Workbook As New Workbook("c:\test.xls")<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Dim Ws As Worksheet = Workbook.Worksheets(0)

Dim RowCount As Int32 = 0

For RowCount = 0 To 1

If Ws.Cells.GetCell(RowCount, 0).Value IsNot Nothing Or Ws.Cells.GetCell(RowCount,1).Value IsNot Nothing Then

'Do Something

End If


The error occurs if the contents of the first row is deleted or pasted over.

How do we test for a null value?

Thanks for your excellent Support,

Current Customer Cluehawk.


Thanks for your posting and using Aspose.Cells for .NET.

For performance and better handling of checking the cell instantiation, please use the Worksheet.Cells.CheckCell() method.

CheckCell will return you null if the cell has not been instantiated.

Now, if the CheckCell() returns you a Cell reference, you can then check it if this Cell has some value or it is empty using Cell.StringValue property.


Cell.StringValue=="" means the Cell is present but it has no values or it is empty.

Thanks for your Quick reply.

However, we are still recieving some errors on uninstantiated cells using the checkcells() method.

Is there an example of using this method so we can verify that we are using it correctly.




Thanks for your posting and using Aspose.Cells for .NET.

Please check the following code. It illustrates the points, I mentioned earlier. As you see in the code, although cell A1 did not exist earlier, but Aspose.Cells created it if you will access it via Worksheet.Cells[string name]

Then you check if it is empty by using Cell.StringValue property. After that you check if the cell A2 exists or not using CheckCell method.

Please check the console output of this code. I have commented the code for your better understanding.


Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];

//Cell A1 does not exist, but if you will access it

//like this, Aspose.Cells will instantiate it.

//Means, the reference to cell A1 will not be null, so the

//the below line will print A1 exists: true

Cell cellA1 = worksheet.Cells[“A1”];

Debug.WriteLine("A1 exists: " + (cellA1 != null));

//Since, cellA1 is not null, so now you would like to check

//if it’s value is empty, you can check it like this

Debug.WriteLine("A1 is empty: " + (cellA1.StringValue == “”));

//Cell A2 also does not exist, but if you will access it

//using CheckCell, it will not be instantiated

//Means, the reference to cell A2 will be null and

//the below line will print A2 exists: false

Cell cellA2 = worksheet.Cells.CheckCell(1, 0);

Debug.WriteLine("A2 exists: " + (cellA2 != null));

Console Output:
A1 exists: True
A1 is empty: True
A2 exists: False