Active worksheet



Does Aspose.Excel can provide which tab is active(selected) after openning the file?



Dear Mark,

Thanks for your consideration.

The answer is Yes. You can use Worksheets.SetActiveSheet method.

But in the evaluation license, The above method will not take effect. The license worksheet will always show after openning the file.


My questions is on GET not SET.
I need to get an active sheet after reading excel doc, not setting it.



Dear Mark,

Please download hotfix

I add a new property Worksheets.ActiveSheetIndex. It will return the active sheet index.

And about two problem xls file you sent to me:

Problem.xls is an Excel 5.0/7.0 file. Please use Excel2000 open it and save as an Excel2000 file. Then please remove the password which protected the workbook. Aspose.Excel currently only support protection to sheet/workbook without password.

Problem2.xls openning bug is fix in the hotfix.


hi lowrense,

one of the excel I sent you problem2.xls is reporting the following exception error
“Formula result is not string.” in line 38.

What does it means?



Dear Mark,

When this exception is reported?

If you use the Cell.StringValue to get a string value of a cell, if this cell contains a formula and the formula result is not a string, then this exception will be thrown.


dear lowrence,

I am trying to get text values of every cell in a simple loop to build an xml out of it.

For c = 1 To colCount
Dim cellval As String = sheet.Cells.Item(r, c).StringValue
If Not IsNothing(val) AndAlso val.Length > 0 Then
writer.WriteAttributeString(“Fld” & c.ToString(), val)
End If


what am I doing wrong?



Dear Mark,

I think that one of these cell contains formula, and the formula is not a string formula.
For example:
Cell B2 contains a formula:"=A1+B1".

Dim cellval as String = sheet.Cells.Item(“B2”).StringValue

The above line code will throw this exception.

You can catch this exception and deal with your own code.