Setting styleflag properties

Thanks Babar,

I changed the enumerations as specified, but I still get a nullpointer exception :frowning:

I’ll try to send you my code.

Regards,
Hendrik

Hi,


I am sorry to know that you are still facing the said problem. Could you please give it a try to latest version 8.6.2.4 in your original environment? By the way, I do not have experience with RPG nor it’s environment so I would request you to please recreate the problem in a simple Java console application and share it here, if the problem persists with latest version.

Hi,



Even with the lastest version I have the same problem.



Can you try this ?





public class asposetest {

public static void main(String[] args) {



System.out.println(“Test”);



//Instantiating a Workbook object

Workbook workbook = new Workbook();

Worksheet sheet = workbook.getWorksheets().get(0);



int index = sheet.getConditionalFormattings().add();



FormatConditionCollection fcs = sheet.getConditionalFormattings().get(index);



//Sets condition formulas.

int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE,OperatorType.BETWEEN,“50”,“100”);



FormatCondition fc = fcs.get(conditionIndex);



fc.getStyle().setBackgroundColor(Color.getRed());



//Saving the Excel file

workbook.Save("/Home/uhg016/condform.xlsx");



}



}





Thanks

I don’t have much experience with java.

Do you know what’s causing this compilation error ? Probably a missing import ?

asposetest.java:15: error: cannot find symbol
Worksheet sheet = workbook.getWorksheets().get(0);
^

You can ignore this last post

HGOAS4:
Hi,

Even with the lastest version I have the same problem.

Can you try this ?

public class asposetest { public static void main(String[] args) {
System.out.println("Test");

//Instantiating a Workbook object
	Workbook workbook = new Workbook();
	Worksheet sheet = workbook.getWorksheets().get(0);
	
	int index = sheet.getConditionalFormattings().add();

    FormatConditionCollection fcs = sheet.getConditionalFormattings().get(index);

	//Sets condition formulas.
	int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE,OperatorType.BETWEEN,"50","100");

	FormatCondition fc = fcs.get(conditionIndex);

	fc.getStyle().setBackgroundColor(Color.getRed());

	//Saving the Excel file
	workbook.Save("/Home/uhg016/condform.xlsx");
		
}

}

Thanks


Hi Hendrik,

Thank you for sharing the code snippet. I have executed it on my side while using the latest version of Aspose.Cells for Java 8.6.2.4. I am afraid, I am not able to observe any exception with this code segment. However, I have noticed that you haven’t assigned the cell range on which conditional formatting would be applicable, that is the reason when I loaded the spreadsheet in Excel application, no corresponding conditional formatting rule was found. In case you are accessing the said rule in your code, you may receive Null Pointer Exception, but not with the current segment. Please also note that I have carried out the tests on a Windows based machine (Windows 10 x64) against JDK 1.8, whereas you appear to be executing the code on a Linux based machine. Please modify the code as follow and give this scenario another try in a Java console application against Aspose.Cells for Java 8.6.2.4. In case the problem persists, please provide more details about your environment, such as follow. We will try our best to simulate the environment on our side to reevaluate the scenario.

  • Operating system version & architecture
  • JDK vendor & version
  • JVM arguments, if any

Java

Workbook workbook = new Workbook();
Worksheet sheet = workbook.getWorksheets().get(0);
int index = sheet.getConditionalFormattings().add();
FormatConditionCollection fcs = sheet.getConditionalFormattings().get(index);
int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE,OperatorType.BETWEEN,“50”,“100”);
FormatCondition fc = fcs.get(conditionIndex);
fc.getStyle().setBackgroundColor(Color.getRed());

CellArea area = CellArea.createCellArea(0, 0, 0, 0);
fcs.addArea(area);


workbook.save(dir + “condform.xlsx”);

Thanks Babar Raza,



I finaly managed to execute this in a small java program.



Attached you can find the stderr log.



Thanks again.

HGOAS4:
Thanks Babar Raza,

I finaly managed to execute this in a small java program.

Attached you can find the stderr log.

Thanks again.

Line 20 in my java source :

int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE,OperatorType.BETWEEN,"50","100");

Hi again,


Thank you for sharing the error details, however, I am not sure why you are experiencing this problem where I am not able to replicate it on my side. Please share the environment details as requested earlier as the problem could be related to it. By the way, have you experienced this issue with latest version 8.6.2.4?
babar.raza:
Hi again,

Thank you for sharing the error details, however, I am not sure why you are experiencing this problem where I am not able to replicate it on my side. Please share the environment details as requested earlier as the problem could be related to it. By the way, have you experienced this issue with latest version 8.6.2.4?

Hello,

Yes, we’re having the problem using version 8.6.2.4

We are working on iSeries (AS/400)

java version "1.7.0" Java(TM) SE Runtime Environment (build pap6470sr8-20141026_01(SR8)) IBM J9 VM (build 2.6, JRE 1.7.0 OS/400 ppc64-64 Compressed References jvmap6470sr8-20141026_01_cr (JIT enabled, AOT enabled) J9VM - R26_Java726_SR8_20141013_1240_B217026 JIT - r11_20141003_74578 GC - R26_Java726_SR8_20141013_1240_B217026_CMPRSS J9CL - 20141013_217026) JCL - 20141004_02 based on Oracle 7u71-b13

Hi,


It will not be easy (or possible) to simulate the platform (iSeries AS/400) however, we can try the scenario against IBM’s J9 VM on windows as well as available Linux installation. Moreover, if you can spare me some time, I will discuss this matter with the product team to get some updates.

That would be fantastic !
Thanks a lot !

Hi Hendrik,


This is to update you that I have performed tests by configuring IBM’s JDK 1.7 on Windows 10 x64 as well as on Ubuntu 14.04 Desktop. Unfortunately, I am still not able to replicate the said exception on my end. Moreover, I was not able to get in touch with the product team in order to get their opinion regarding the said problem as they were busy publishing the maintenance releases. I will contact them again on next working day (Monday) and post the findings here for your reference.

Please keep us posted in case you are able to resolve the problem.

Ok, please keep me informed.



Something else …

The old way of inserting Date/time values gives problems.



I use “putValue” with a “java.util.date” object, but this fails …



What should I do to make this work ?

Thanks !

Hi Hendrik,


I have checked, there is no problem in inserting java.util.Date object as cell value while using Cell.putValue method. However, inserting an object of java.util.Date as cell value will not convert it automatically, so you may use the overloaded version of the said method that accepts String as first parameter and Boolean as second. This way, you will be able to insert the Date object’s string value and auto convert it based on the second Boolean parameter.

Java

Workbook workbook = new Workbook();
java.util.Date date = new java.util.Date();
Cell cell = workbook.getWorksheets().get(0).getCells().get(“A1”);
cell.putValue(date.toString(), true);
workbook.save(dir + “output.xlsx”);

Hi again,


This is to update you that I have logged an official request for the product team’s review against the problem of java.lang.NullPointerException being observed while adding the format condition to the collection. The tracking code for your future reference is CELLSJAVA-41652. Please note, as we are not able to replicate the said problem on our side therefore we may require some time to analyze the problem, and to pin point the problem cause. As soon as we receive any updates in this regard, we will post here for your kind reference.

In case you are able to resolve the problem, please notify us here so we could take appropriate actions to hold the investigation.

Thanks a lot ! I will keep an eye on it.

Hello,



Inserting date objects works after changing the method’s signature.



putValue with ‘java.lang.Object’



I discovered the conditional format is also causing troubles when I try to open a Workbook that contains conditional formatting.



When I try to open the file attached I also receive a nullpointer error. After removing the conditional formatting, the problem is gone…



Maybe this can help in solving CELLSJAVA-41652



Thanks !

Hi Hendrik,


I have checked your provided spreadsheet, and I am able to load it without observing any exception. I doubt that latest revision of Aspose.Cells for Java is being referenced in your project. Could you please print the version using the following statement?

Java

System.out.println(CellsHelper.getVersion());

Hello,

This is the output

8.6.2.4