Free Support Forum - aspose.com

Urgent: Problems with 1.7.3.2

Laurence,

we are about to go live with our product around friday this week and all of a sudden I realised that there seems to be a problem with Custom cell formats and Column AutoFit.

- When I create a new style and set Number to 0 and assign a custom format, it does not take into account the custom format anymore
- When you perform Worksheet.AutoFitColumn on the first column of a range of merged columns (coming from a designer file), this first column will be resized to hold the full text, even though it was merged with adjecent columns.

Both of these were not the case with 1.6.3.3

I hope you can help me out of this

Thanks

Regards

Kai

I need to correct myself: The AutoFitColumn behaviour is there in 1.6.3.3 as well, but the custom format issue did not exist in 1.6.3.3.

Kai

Dear Kai,

Sorry for the bug.
I will fix the AutoFitColumn right now. But about the custom format, I don’t exactly catch your meaning. Do you mean the following?

style.Number = 0;
style.Custom = “mm-dd-yyyy”;

Does not the custom format take effect?

Laurence,

excatly this is the case. I have a method that will set up a style for me and somewhere within this method, the following happens

style.Number = 0
style.CustomFormat = "0.00%"

The format is not taken into account though whereas with 1.6.3.3. it was.

Regards

Kai

Dear Kai,

Please download hotfix 1.7.4 and have a try.

Laurence,

sorry, but the custom format still does not show.

Regards

Kai

Dear Kai,

I’m sorry that the bug still exists. Could you post you code here?
Thanks.

Laurence,

here it comes. I have checked my code and I do supply 0 for “format” and “0.00%” for
"customFormat".


internal Excel.Style GetXLStyle(Excel.Excel excel, bool bold, bool italic, int format, string customFormat, Excel.TextAlignmentType horzAlignment, Color color, Color backColor, string fontName)
{
string key = String.Format(
“{0}:{6}:{1}:{2}:{5}:{3}:{4}:{7}”,
format.ToString(),
color.ToString(),
bold.ToString(),
backColor.ToString(),
horzAlignment.ToString(),
italic.ToString(),
(customFormat == null ? “” : customFormat),
(fontName == null ? “” : fontName)
);

Excel.Style style = null;

try { style = excel.Styles[key]; }
catch {}

if(style == null)
{
style = excel.Styles[excel.Styles.Add()];

style.Name = key;
style.Number = (byte)format;
style.HorizontalAlignment = horzAlignment;

if(customFormat != null)
{
style.Custom = customFormat;
}

if(backColor != Color.Empty)
{
style.ForegroundColor = backColor;
}

if(fontName != null && fontName.Length > 0)
{
style.Font.Name = fontName;
}
style.Font.IsBold = bold;
style.Font.IsItalic = italic;

if(color != Color.Empty)
{
style.Font.Color = color;
}
}

return(style);
}

Dear Kai,

Thanks for your help. It has been fixed in fix 1.7.4.1. Please download it.

Laurence,

thanks for your help. However, a new one exists that has to do with AutoFitColumn:

When I specify a custom format of “0.00 [$EUR]” 1.6.3.3 did size the columns a bit
too wide, but with 1.7.4.1 they are too narrow resulting in hashes “####” to be shown.

Regards

Kai

Dear Kai,

If you use a custom number format to format a number, it’s hard to know the result display length.

Please download fix 1.7.4.2 and have a try.

If you use a custom format, I suggest that you set the column width by you own code since you know what’s the appropriate width.

Laurence,

sorry to not have replied earlier. Thanks for this. Looks good for us.

Regards

Kai