Color

Last post 02-10-2012, 11:14 AM by mshakeel.faiz. 3 replies.
Sort Posts: Previous Next
  •  02-10-2012, 6:56 AM 360717

    Color Java

    Attachment: Present (inaccessible)
    Hi,

    Can you explain me why method Color.getR() return value "-1"(for red text in cell) but every Color component must have a range 0 to 255? Can you check this with following code and attached file? What is a problem?

    String path = "/home/emisia/Desktop/formatting-test.xls";
    Workbook workbook = new Workbook(path);
    Worksheet worksheet = workbook.getWorksheets().get(0);
    Cell cell = worksheet.getCells().get(0);
    FontSetting[] characters = cell.getCharacters();
    FontSetting fontSetting = characters[4];
    Color color = fontSetting.getFont().getColor();
    int red = color.getR();
    System.out.println(red);

    Thanks,
    Bojan
     
  •  02-10-2012, 10:12 AM 360786 in reply to 360717

    Re: Color

    Hi,

    Please use this code instead, it will return the correct color of the 4th character, which is black, so red part is 0.

    I have highlighted the changes in red.

    The output of this code will be 0, which is correct.

    Java
    String path = "F:\\Shak-Data-RW\\Downloads\\formatting-test.xls";

    Workbook workbook = new Workbook(path);
    Worksheet worksheet = workbook.getWorksheets().get(0);
    Cell cell = worksheet.getCells().get(0);
    FontSetting[] characters = cell.getCharacters();
    FontSetting fontSetting = cell.characters(4, 1);
    Color color = fontSetting.getFont().getColor();
    int red = color.getR();
    System.out.println(red);


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
  •  02-10-2012, 11:01 AM 360796 in reply to 360786

    Re: Color

    Hi,

    thanks for reply but this is not what I want. Problem is that the method Color.getR() return value "-1" for some Color and that is a problem, because range for Color component is 0 to 255. My code cannot operate with this value, pleas help me with this because this stop my project.

    Thanks,
    Bojan
     
  •  02-10-2012, 11:14 AM 360799 in reply to 360796

    Re: Color

    Hi,

    Actually, 255 means -1 if the byte is signed.

    You should read unsigned byte, then you will get a value from 0-255.

    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML