We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Formatting the Content from & to &- < < when generating the excel file


I'm new to the aspose, when generating the excel report from the datatable, we need to render follwing character in the given below format.

From To

& - &

< - <

> - >.

Actually i'm storing the data in the database like "The & test" this. When generating the excel file i need the out as 'The & test".

Please help me to solve this issue.

Thanks & Regards



Thanks for your inquiry.

I think Ms Excel does not provide such feasibility to render your special characters into your desired format, so does Aspose.Cells. So, I am afraid, Aspose.Cells does not provide such conversion. I think you have to use your own code to replace those special characters to your desired characters/formats after you import data from your data source.

Thank you.


I have also written a simple code if it can provide some help for you to achieve your task. You can change/update or add to the code segment accordingly, it is just a hint if it could work for you.

Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

//Define Area: A1:A11;
CellArea area = new CellArea();
area.StartRow = 0;
area.StartColumn = 0;
area.EndRow = 40;
area.EndColumn = 20;

Aspose.Cells.Cell foundCell;
Aspose.Cells.Cell prevCell = null;

//Scan the area
//Search for “&” string in an area and replace it with “&”.
foundCell = worksheet.Cells.FindStringContains("&", prevCell,false, area);
if (foundCell == null)
string val = foundCell.StringValue.Replace("&", “&”);

prevCell = foundCell;

} while (foundCell != null);


Thank you.