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

Issue with grayscale #9

Open
azukaar opened this issue Aug 11, 2015 · 6 comments · May be fixed by OrderMyGear/js-xlsx#2
Open

Issue with grayscale #9

azukaar opened this issue Aug 11, 2015 · 6 comments · May be fixed by OrderMyGear/js-xlsx#2

Comments

@azukaar
Copy link

azukaar commented Aug 11, 2015

Just opening and re-writing a file will mess up the grayscale bgcolor/fgcolor in the file :

image

Will output

image

@protobi
Copy link
Collaborator

protobi commented Aug 11, 2015

perfect, thanks!

@azukaar
Copy link
Author

azukaar commented Aug 11, 2015

I tried to have a look at the source for a fix, but sory for now I didn't find anything relevant, seems like the theme+tint is working properly but not converted correctly to the corresponding grayscale. I was wondering if Excel wasn't actually using the Alpha channel to process them (considering that current implementation hard-translate argb = FF + rgb). I'll let you know if I find anything (because if the issue become too important on our current project I'll to investigate more on it)

@ilia-khaustov
Copy link

@azukaar I managed to paint cell to a needed shade of grey using following:

 cell.s.fill = {
    fgColor: { rgb: 'DFDFDF' }
 } 

I found out that fgColor value is used as a background for a cell despite its name seems quite opposite. fgColor holds a foreground color for a patternFill with a 'solid' patternType and has nothing to do with font color in a cell. So, when you use bgColor without specifying patternType to 'none', it defaults to 'solid' in js-xslx. This is how it looks in XML:

<fill>
  <patternFill patternType="solid">
    <bgColor/>
  </patternFill>
</fill>

When cell has a patternFill with a 'solid' patternType it changes cell background color to the patternFill fgColor. If it is not specified, system foreground color is used (usually black).

More info here: http://stackoverflow.com/questions/10756206/getting-cell-backgroundcolor-in-excel-with-open-xml-2-0

@azukaar
Copy link
Author

azukaar commented Aug 28, 2015

Thanks for the info
Thought I don't directly use the style params itself, they are imported from Excel and re-exported without even being "read". So I don't really want to read the file just to replace grayscale. I guess there's something to be fixed in the parser directly

@fghpdf
Copy link

fghpdf commented Sep 12, 2016

Do you know how to solve it?(´・_・`)

@fghpdf
Copy link

fghpdf commented Sep 12, 2016

I solved it today
my code contains
if(color.theme) { do something }
but the color.theme will be 0 , and present false

Notice, the theme must be transfer!
Look

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

Successfully merging a pull request may close this issue.

3 participants