Free Support Forum - aspose.com

Custom color- Color.fromArgb- java.lang.NoSuchMethodError- aspose cells 7.0.1

Refactored our Java impl cells 2.5.x to 7.0.1, Java 1.5 version

It compiles but at runtime getting
java.lang.NoSuchMethodError: com.aspose.cells.Color.fromArgb(I)Lcom/aspose/cells/Color;
(this is for the 1 argument Color.fromArgb) from the following code:

public static final com.aspose.cells.Color COLOR_LEVEL_1 = com.aspose.cells.Color.fromArgb(0x009900);

same issue with the 3 argument version, noSuchMethodError again
…Color.fromArgb(0x00,0x99,0x00);

I deployed all the lib jar (minus bcprov-jdk15-146.jar) to my WEB-INF/lib just like I had previously deployed aspose-cells-2.5.0.jar

jars deployed:
aspose-cells-7.0.1.jar
dom4j-1.6.1
jsr173_1.0_api.jar
stax2-api-3.0.2.jar
woodstox-core-asl-4.0.8.jar


Hi,

Your jar files seem to be ok.

Please try the latest version:
Aspose.Cells for Java (Latest Version) and let us know your feedback.

It is running now, but the custom color is not being applied.
Will troubleshoot my code to confirm I’m applying it correctly.

In terms of correctness… found the following issue with technical article
Colors and Palette is inconsistant with the javadoc and impl

  • Sample has
    • workbook.getWorksheets().getPalette().changePalette(color,55); is incorrect
  • your javadoc and the impl has
    • workbook.changePalette(colorToAdd, newColorIndex);

The limited color index and means of messing with it is rather annoying.
I need to add new colors without stepping on ones already added,so I wrote the following, but it would be much nicer if the API handled it:

public static void addColorToPalette(Workbook wb, Color colorToAdd){
if((wb != null) && (colorToAdd != null) && !wb.isColorInPalette(colorToAdd)){

//find added colors
List defaultColors = Arrays.asList(AsposeExcelUtility.defaultWorkbook.getColors());
List workbookColors = Arrays.asList(wb.getColors());

int newColorIndex = 55;

//find the first default color index (first available index)  
for(int i = 55; (i >= 16) && !workbookColors.get(i).equals(defaultColors.get(i)) ; i–){
//find the first default color index (first available index to replace)
newColorIndex–;
}
wb.changePalette(colorToAdd, newColorIndex);  
}
}

Hi,

It’s good, your problem is sorted out.

Xls format support less colors but Xlsx format support much more colors, if you save your file in xlsx format, then you don’t need to play with palette.

We will consider and investigate your request and see if it could be implement inside the Api.

Does that mean there is no upper index limit of 55 in the pallette for xlsx format?

My client is very specific on colors so we went with custom coloring.

I have already noticed that you can add unlimited conditional formats when saving to xlsx, but it breaks xls if you add more than three.

Hi,

Xls support 256 colors and you have to change palette everytime, if you need more colors. Xlsx almost support every color.

If you find any bug, then please report with sample code and source files (if any).

Hi,

If you are applying color for XLS files and the color is custom oriented (that does not present in the MS Excel 97 - 2003 standard color palette (that has only 256 colors)), you need to add the colors to the color palette first. MS Excel 2007/2010 formats like XLSX has huge list of colors, so you don’t need to add them to palette any longer.

And, we will update the code segments on the document soon, thank for pointing it out:

Colors and Palette

Thank you

Hi,

I have updated the document accordingly now:

Colors and Palette

Thank you.