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

Hi

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

mk_mur.

Hi,

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.

Hi,

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();
workbook.Open(“e:\test\spchars.xls”);
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 “&”.
do{
foundCell = worksheet.Cells.FindStringContains("&", prevCell,false, area);
if (foundCell == null)
break;
MessageBox.Show(foundCell.Name);
string val = foundCell.StringValue.Replace("&", “&”);
foundCell.PutValue(val);


prevCell = foundCell;

} while (foundCell != null);


workbook.Save(“e:\test\outspchars.xls”);


Thank you.