How to unset a style?

Hello,

I did set a style to a cell like so:

var ods = new Workbook(OdsPath);

var highlightStyle = ods.GetNamedStyle(“Highlight”);
var flag = new StyleFlag();
flag.All = true;

var cell = blabla get the cell
cell.SetStyle(highlightStyle);

How can I unset the style so that it uses back the default style of the sheet?

I tried doing:

cell.SetStyle(ods.DefaultStyle);

Neither are working, it’s not setting the default style.

Any ideas?

@Xhat,
Thank you for your query.
You may create the workbook default style and use it wherever required. Please create a style as follows and share the feedback.

// Create a style object .
Style style = ods.CreateStyle(); 
cell.SetStyle(style);

If it does not fulfill your requirement, please share the sample ODS file, runnable console application and image showing difference in program output and expected output for our reference. We will analyze it here and share our feedback soon.

EDIT: Problem solved. I was doing something funny so obviously the result weren’t what I wanted.

I was able to reproduce another issue with the date format being wrongly recognized though.

See original.ods the right date format and test.ods the outputted format.

@Xhat,
Thank you for the feedback and glad to know that your issue is resolved.

Regarding your second issue of recognition of date format, I have tried your sample code but could not observe any issue. The comparison image is shared here for your reference. Please check it and explain the issue in detail for our analysis.

DatesComparison.png (59.7 KB)

Please check original.ods for how the date is before program execution

@Xhat,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic. Issue is reproduced using following sample code.

var ods = new Workbook(@"original.ods");
ods.Save(@"test2.ods");

This issue has been logged as

CELLSNET-47348 – Date format changed in ODS file after loading and saving it

@Xhat,

This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-47348”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

1 Like

@Xhat,
Please try our latest version/fix: Aspose.Cells for .NET v20.4.6 (attached)

Your issue should be fixed in it.

Let us know your feedback.

Aspose.Cells20.4.6 For .NetStandard20.Zip (5.3 MB)
Aspose.Cells20.4.6 For .Net2_AuthenticodeSigned.Zip (5.3 MB)
Aspose.Cells20.4.6 For .Net4.0.Zip (5.4 MB)

Fixed, thanks!

@Xhat,

Good to know that your issue is sorted out by the new fix/version. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSNET-47348) have been fixed in Aspose.Cells for .NET v20.5. This message was posted using Bugs notification tool by Amjad_Sahi