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

Free Support Forum - aspose.com

Setting styleflag properties

Hello,



We use aspose cells for a long time (older version). We are now reviewing our sources to use the recent version of aspose.



We discovered this requires a lot of changes :frowning:



Doing this changes we have 2 major problems (until now) :

- We can no longer insert “double” values into cells (signature for “setValue” does no longer exist)

***************************************

- we are working on iSeries and cannot access object properties directly, so we need setter-/getter-methods

I think no “setter” exists for setting the StyleFlag properties to TRUE or FALSE

I would like to set “ALL” to TRUE …



Can this be checked/fixed ?



Thanks a lot !!

Hi Hendrik,


Thank you for contacting Aspose support.

Which version of Aspose.Cells for Java API has the above mentioned issues? I have checked the latest release at the moment, that is; 8.6.2.4 (attached), and I am able to access & use the StyleFlag.setAll method. In case your scenario is different, please share the code snippet for better understanding. Regarding the Cell.setValue, please use Cell.putValue method instead. One of the overload version of the Cell.putValue method can accept a double value as parameter.

Thanks a lot for the quick reply !

We are testing with version 8.5.0

I will try your suggestions.

Both solutions are also working with version 8.5.0 !
Thanks a lot !

I will proceed with the changes; Maybe you’ll hear me again :slight_smile:

Hi Hendrik,


Thank you for the confirmation. Please feel free to write back in case you need our further assistance with Aspose APIs.

Hello,

Can you check method “setPattern” for a style object ? I can use it 2 times, but on the third call I get memory problems. Are all used objects free’d ?

Thanks for checking!

Hi Hendrik,


Thank you for writing back.

I have tried to investigate the matter with following piece of code, however, I am not able to observe any exception. Please note, as per company policy we have to test the issue with most recent release so I have used Aspose.Cells for Java 8.6.2.4 for my testing. Further more, Style objects can be created in different ways, I am not sure how your code look so I request you to please share your executable code snippet (that replicates the problem) along with input spreadsheet, if any. Please also identify which statement throws the error and what are the details of the error. These details will help us identify the problem, and we will be in a better position to assist you further in this regard.

Java

Workbook book = new Workbook(dir + “book1.xlsx”);
Style style = book.createStyle();
style.setBackgroundColor(Color.getBlue());
style.setForegroundColor(Color.getYellow());
style.setPattern(BackgroundType.VERTICAL_STRIPE);
Cell A1 = book.getWorksheets().get(0).getCells().get(“A1”);
A1.setStyle(style);
Cell A2 = book.getWorksheets().get(0).getCells().get(“A2”);
style.setPattern(BackgroundType.DIAGONAL_CROSSHATCH);
A2.setStyle(style);
Cell A3 = book.getWorksheets().get(0).getCells().get(“A3”);
style.setPattern(BackgroundType.THICK_DIAGONAL_CROSSHATCH);
A3.setStyle(style);
book.save(dir + “output.xlsx”);

Hello,



Attached you can find the dump I get.

It looks like a memory problem that occurs on creation of the 4th style.



It’s difficult to post the code (because it’s written in RPG, calling java procedures), but these are the steps we take :



1 - Create a new workbook

2 - Create different styles

* Create style object

* Retrieve the font and specify some font settings

* Retrieve the borders and specify some border settings

* Set the pattern + foreground color (in this sequence)

* …



The javadump happens when setting the pattern.



Regards,

Hendrik

Hello,



Is it possible to check the garbage collection ?



Thanks a lot !

HGOAS4:
Hello,

Attached you can find the dump I get.
It looks like a memory problem that occurs on creation of the 4th style.

It’s difficult to post the code (because it’s written in RPG, calling java procedures), but these are the steps we take :

[code]
1 - Create a new workbook
2 - Create different styles
* Create style object
* Retrieve the font and specify some font settings
* Retrieve the borders and specify some border settings
* Set the pattern + foreground color (in this sequence)
* …

The javadump happens when setting the pattern.

Regards,
Hendrik
[/code]


Hi,

I am afraid, the shared dump didn’t allow me to track the problem. Regarding your flow of the application, have you tried the similar code in a simple console application? If yes, were you able to replicate the same exception? Moreover, I request you to give a try to the latest version (download link shared earlier) in your original environment just to check if the said behavior is version specific.

As I narrated earlier that there are different ways to initialize an object of the Style class where the most appropriate one is to use the Workbook.createStyle as it adds the style object to the pool after instantiating. If you are using the default constructor of the Style class to initialize it then try the above mentioned method. In case the problem persists (with latest release) please create a simple Java console application replicating the issue and share it here for further investigation.
HGOAS4:
Hello,

Is it possible to check the garbage collection ?

Thanks a lot !


Hi,

Aspose.Cells APIs do not provide any APIs to monitor the garbage collection, however, the garbage collection is done automatically. You can search over the internet to find suitable components for monitoring purposes.

Hello,

I found the problem.
I cleaned up some references that were still used … Issue solved

Another question :
What’s the best (new) way to create a CellArea ?

In the past we used : CellArea(int, int, int, int) but this does not work anymore

I tried : MyArea = CellArea(); --> ok so far
MyArea.createCellArea(int, int, int, int)
but this fails :frowning:

Does this procedure return a value/object ?

Hi Hendrik,


It is good to know that you are able to bypass the previously mentioned issue. Regarding the CellArea, you can create its instance using the default constructor then set the boundaries using the start/end row/column properties as demonstrated below.

Java

CellArea cellArea = new CellArea();
cellArea.StartRow = 0;
cellArea.StartColumn = 0;
cellArea.EndRow = 10;
cellArea.EndColumn = 10;

Thanks for the quick reply, but as mentioned earlier I need methods to set properties. I cannot set the properties like specified :frowning:

Hi Hendrik,


I am afraid, CellArea class does not have the getter/setter for it’s properties. However, you may use the factory method createCellArea exposed by the CellArea class to create an instance of CellArea. Please check the following piece of code for better understanding.

Java

CellArea area = CellArea.createCellArea(0, 0, 10, 10);

Ok, I managed to do that by defining it as static method.
Thanks

Hello, here I am again :wink:



Setting a conditional format causes problems

Can you check the enumarations we used with the old version of aspose ?



I get a null pointer exception on “addCondition”…

I do not pass any null pointers, so maybe the enumerations are not ok.



Or …

Should there already be an area added to the formatconditionCollection ??



Thanks again

Hi Hendrik,


Please check the detailed article on Adding Conditional Formatting Rules with latest APIs.

That’s exactly what I’m doing (but I get a null pointer exception). Can you check the enumerations for me please ?

Thanks

Hi again,


The constant names for the class OperatorType are different than what you have shown here. Please check complete details of OperatorType class according to recent APIs.