Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function to support inserting custom color into IndexedColors Map #1123

Closed
wants to merge 1 commit into from

Conversation

deleteJ
Copy link
Contributor

@deleteJ deleteJ commented Jul 23, 2023

this closes #979

@tonyqus
Copy link
Member

tonyqus commented Jul 29, 2023

#699

@tonyqus
Copy link
Member

tonyqus commented Jul 29, 2023

The size of IndexedColor is fixed. We cannot simply add new custom color to indexed color list

https://github.com/ClosedXML/ClosedXML/wiki/Excel-Indexed-Colors

@tonyqus tonyqus self-requested a review July 29, 2023 00:21
@tonyqus tonyqus added this to the NPOI 2.7.1 milestone Jul 29, 2023
@tonyqus tonyqus changed the title 1. add function to support inserting custom color into IndexedColors Map add function to support inserting custom color into IndexedColors Map Jul 29, 2023
@tonyqus
Copy link
Member

tonyqus commented Jul 29, 2023

@tonyqus tonyqus marked this pull request as draft July 29, 2023 00:48
@deleteJ
Copy link
Contributor Author

deleteJ commented Jul 29, 2023

oh, i'll a take a look, thanks

@deleteJ
Copy link
Contributor Author

deleteJ commented Jul 31, 2023

questions:

  1. why in IndexedColors we have some index not used(like 32-39)?
  2. I should add API to allow uses to replace indexedColors on some index?

@Bykiev
Copy link
Collaborator

Bykiev commented Aug 1, 2023

  1. I should add API to allow uses to replace indexedColors on some index?

The API is already available:

public void SetColorAtIndex(short index, byte red, byte green, byte blue)

@Bykiev
Copy link
Collaborator

Bykiev commented Aug 1, 2023

  1. why in IndexedColors we have some index not used(like 32-39)?

These indexes are free and should be used for custom colors

@deleteJ
Copy link
Contributor Author

deleteJ commented Aug 6, 2023

Hi @Bykiev
thanks for your reply...

I'm quite new to this npoi project, here's some learnings

  1. HSSFWorkBook can use getCustomPalette and SetColorAtIndex to use its own RGB color
  2. XSSFWorkBook do not have such API, but only XSSFColor constructor
public XSSFColor(IndexedColors indexedColor)

but this requires color registed in class IndexedColors

public static IndexedColors ValueOf(int index)
{
    if(mappingIndex.ContainsKey(index))
        return mappingIndex[index];
    throw new ArgumentException("Illegal IndexedColor index: " + index);
}
  1. This issue requests APIs to add new color on empty index
  2. should we allow to replace existing default indexed colors, I prefer NO...

correct me if anything wrong, thanks

@tonyqus
Copy link
Member

tonyqus commented Aug 12, 2023

@deleteJ
Copy link
Contributor Author

deleteJ commented Aug 21, 2023

On POI side, they(IndexedColors) have index [0, 31], [40, 63], 56 colors supported

but out of these 56 colors, there are 9 colors which are duplicated, index [0, 7] and index 27 (LIGHT_TURQUOISE)
that's why in current NPOI indexedColors we don't have these indexes but actually they're same

@tonyqus tonyqus closed this Apr 26, 2024
@tonyqus tonyqus removed this from the NPOI 2.7.1 milestone May 9, 2024
@tonyqus
Copy link
Member

tonyqus commented Sep 22, 2024

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPOI - New Feature - custom color
3 participants