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

Free Support Forum - aspose.com

Superscript in custom cell format rendered as non readable content

Hello ,

I have been trying to print area units m2 and ft2 with ‘2’ as a superscript value.

I used
style.Custom = "#,##0.00 "+ variable;
to specify the required style. The variable is a string which contains “m²”.

When I use this style , the excel file saved as xlsx prompts that there is non readable content.
It repairs when I ask to and all the area units disappear.

However , it works when I render it as pdf by using wb.Save() with pdf format.
Can you please suggest if I am doing something wrong or if I have to escape the strings in a certain manner ?

I use 7.5.1.0 version of aspose cells .NET .
Thanks,
Mahesh

Hi,

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

Please download and try the latest version Aspose.Cells for .NET 7.5.2 and see if it works fine.

If your problem still occurs, then please provide us your sample project replicating this issue with the latest version. We will look into it and help you asap.

Hi ,

The problem still persists even after installing the latest version. The units show up as m2 in pdf version but are rendered as non readable content in excel. When I try to open excel ,it asks for recovery and all symbols are gone.

The following is a snippet of code I use .

bool pdf = true;
sheet.Cells[i,j].PutValue(2345);
Style st = sheet.Cells[i,j].GetStyle();
st.Custom = “#,##0 m²”;
sheet.Cells[i,j].SetStyle(st);

if (pdf)
wb.Save(ms, SaveFormat.Pdf);
else
wb.Save(ms, SaveFormat.Xlsx);

I use memory stream to deliver the excel /pdf.
Thanks,
Mahesh

Hi,


Well, I have evaluated your issue in MS Excel, how could you do this in MS Excel, you cannot enter “#,##0 m²” as custom format using Format Cells… dialog box for your value in MS Excel, see the attached screen shot for your reference. I think MS Excel is rightly pointing out the unreadable content in custom formatting as we cannot do this in MS Excel manually.

If you still think that this can be done in MS Excel, please create such file manually in MS Excel with your desired custom formatting, save it and post it here, we will check it soon.

I think for your needs, you should specify superscripts for your data adding it by yourself using Aspose.Cells APIs, see the document for your reference:
http://www.aspose.com/docs/display/cellsnet/Apply+Superscript++and++Subscript+Effects+on+Fonts

Thank you.

Hi ,

Thank you for your hint that it may be an issue with Excel itself. I did some research on writing custom formats in excel and found the way to do it.

style.Custom = “#,##0.00” m²""; is the solution . Any string can be attached to custom format by specifying within double quotes.

It works with Aspose as well. I have attached the manually created file for your reference.

Thanks,
Mahesh

Hi,

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

We have tested your issue with the following code and found it is working fine. The output file shows the cell content in correct format and there is no error in the generated file.

We have attached the output file for your reference.

C#


Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];


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

cell.PutValue(34);


Style style = cell.GetStyle();

style.Custom = “#,##0.00” m²"";

cell.SetStyle(style);


workbook.Save(“output.xlsx”, SaveFormat.Xlsx);