Problem with the Cell.Characters

Hello! I have a problem.
I can’t call Cell.Characters method twise for one Cell:

Cell c=sheet.Cells[“a1”];
string str=“lalalalalalalalala”;
c.PutValue(str);
Characters ch=c.Characters(0,2);
ch.Font.IsSuperscript=true;
ch=c.Characters(4,2); // <-- there Exception thrown!
ch.Font.IsSuperscript=true;

What’s wrong?

Thank you.

Oh! It doesn’t works for other cells too:

Cell c=sheet.Cells[“a1”];
string str=“lalalalalalalalala”;
c.PutValue(str);
Characters ch=c.Characters(0,2);
ch.Font.IsSuperscript=true;
Cell b=sheet.Cell[c.Row,c.Column+1]; //it’s other cell!
Characters h=b.Characters(4,2); // <-- there Exception thrown!
h.Font.IsSuperscript=true;

What’s wrong?

Thank you.

sorry, last post it’s my mistake. I haven’t put value in Cell Smile

Thank you for help! )))
I’ve had old version of Aspose.Excel, now it’s works well!

@zavoloka,
Aspose.Cells has replaced Aspose.Excel that is no more under active development now. This new product Aspose.Cells has rich features to work with individual characters as demonstrated in the following sample code:

// Instantiating a Workbook object
Workbook workbook = new Workbook();

// Obtaining the reference of the first(default) worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];

// Accessing the "A1" cell from the worksheet
Cell cell = worksheet.Cells["A1"];

// Adding some value to the "A1" cell
cell.PutValue("Bold Underline Italic");

// Setting the font of selected characters to bold and colored.
cell.Characters(0, 4).Font.IsBold = true;
cell.Characters(0, 4).Font.Color = Color.Green;

// Setting underline of the specific chars.
cell.Characters(5, 9).Font.Underline = FontUnderlineType.Dash;

//Setting Italic for the specific chars
cell.Characters(15, 6).Font.IsItalic = true;

//Define style to Wrap text in the cell.
Style style = workbook.CreateStyle();
style.IsTextWrapped = true;
//apply the style.
cell.SetStyle(style);
worksheet.AutoFitColumns();

workbook.Save("output.xlsx");

Refer to the following article for more information on formatting selected characters:
Formatting Selected Characters in a Cell

You may try the latest free trail version of this product here:
Aspose.Cells for .NET (Latest Version)

You can test different features of this new product by downloading an executable solution here.