Setting styleflag properties

Hi,


I had tested it with Oracle’s JDK as well as IBM’s and no exception was observed on my end. Anyway, I have provided the said spreadsheet to the product team for their consideration.

Hello,

I took a closer look at the error I receive when using conditional formatting.

java.security.securerandom.nextbytes --> nullpointerexception

Apparently this class was not found !
Searching the www I found I have to extend my classpath directories.
==> /QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit/jre/lib/ext

After doing so the conditional formatting works :slight_smile:
So, No need to spend time on it !
Sorry for the inconvenience and thanks a lot !!

Hi again,


Thank you for sharing the problem cause, and it is good to know that you are up & running again. Please note, we have closed the investigative ticket logged earlier as CELLSJAVA-41652. Please feel free to contact us back in case you need our further assistance with Aspose APIs.

Thanks Babar,



I think most basic things are working now.

However there is one strange thing in applying styles.



When I apply a style to a row everything is ok, but when I apply a style to a cell I have strange behavior.



–> The style is not visible when I do not apply the default style to the row.

–> When I open the result in Excel, and go to a cell with a certain style, the style selection at the top shows ‘DEFAULT’ (see attachment)



I suppose I’m doing something wrong …

Hi,


Are you able to replicate the same problem in simple Java application as well? If so, please post your code along with the input & output spreadsheets so we could investigate the matter on our end.

Hello,

I’m using “getNamedStyle” / “createStyle”.

Can these still be used, or should I use “getStyles.get/add” ? What does “getStyles” return ? Styles or StylesCollection ?

Thanks

Hi,


Please note, Workbook.getStyles method has been marked depreciated and it will be removed from the public APIs very soon. Anyway, getStyles method returns an object of the StyleCollection class. You can use Workbook.getNamedStyle if you know the name of the style to retrieve. In generic, you should use the Workbook.createStyle as it would initialize some aspects of the Style object while adding it to the pool. You can also use the Style objects created with Workbook.createStyle in conjunction with StyleFlag in order to impose the desired styling aspects.

This code shows the problem.
I applied a style to cell(0, 0). The style is visible in the workbook, but the cell is not tagged with that style.

When compiling the code I see that “getStyles” is deprecated … What should I use instead ?

import com.aspose.cells.*;

public class styletest {
public static void main(String[] args) {

//System.out.println(CellsHelper.getVersion()); 
try {
//Instantiating a Workbook object
	Workbook workbook = new Workbook();
	Worksheet sheet = workbook.getWorksheets().get(0);
	
	int styleIdx = workbook.getStyles().add();
	Style style = workbook.getStyles().get(styleIdx);

	style.getFont().setColor(Color.getRed());
	style.setName("Style1");
	
	//Initialize styleflag object.
	StyleFlag flag = new StyleFlag();
	//Set all formatting attributes on.
	flag.setAll(true);

	Cells mycells = sheet.getCells();
	RowCollection myrows = mycells.getRows();
	Row myrow = myrows.get(0);
	Cell mycell = myrow.get(0);
	
	mycell.putValue("Tekst");
	mycell.setStyle(style, flag);
			
	//Saving the Excel file
	workbook.save("styletest.xlsx", SaveFormat.XLSX);
}
	catch(Exception e) 
	 {
	   		 }
}

}

Hi,


Thank you for the code snippet. I am able to observe the mentioned issue, that is; style is being set properly, however, relevant style has not been selected from the available collection of styles when spreadsheet is viewed in Excel. I have to check back with the product team to get a justification for this behaviour.

Regarding, Workbook.getStyles been marked obsoleted, this decision was made on performance grounds where more styles tend to fill in the pool. New mechanism is to use the Workbook.createStyle method as demonstrated below.

Java

Workbook workbook = new Workbook();
Style style = workbook.createStyle();
Hi again,

babar.raza:
Thank you for the code snippet. I am able to observe the mentioned issue, that is; style is being set properly, however, relevant style has not been selected from the available collection of styles when spreadsheet is viewed in Excel. I have to check back with the product team to get a justification for this behaviour.

This is to update you that I have raised the above mentioned concerns with the product team by creating an investigative ticket with Id CELLSJAVA-41659. Please note, as per my testing, when cell A1 is selected, the styles portion of the Excel interface shows that Normal style has been applied on the said cell. I have attached a snapshot here as well for your reference.

We will shortly investigate the matter, and get back to you with updates in this regard.

The issues you have found earlier (filed as CELLSJAVA-41659) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.