rabanti-github / PicoXLSX

PicoXLSX is a small .NET / C# library to create XLSX files (Microsoft Excel 2007 or newer) in an easy and native way
MIT License
52 stars 13 forks source link

Style.BasicStyles.ColorizedText is not working #8

Closed visualczm closed 6 years ago

visualczm commented 6 years ago

hi, why Style.BasicStyles.ColorizedText is not working in my project Style.BasicStyles.ColorizedBackground OK.

help me~~

image demo10 ok image

rabanti-github commented 6 years ago

Hi

It is a bug in the style sub-set. It only ssems to happen if the only style information is a foreground color. I am working on a patch and will update the library as soon as possible.

Can you provide the code segment where you try to assign the color (style) to the text? From the first picture, I only can determine the colorized background. The line with ColorizedText is commented out.

However, there are two attempts:

1. Only colorized foreground text In this case, you coud simply try this code to assign the style to a cell:

workbook.WS.Value("test", Style.BasicStyles.ColorizedText("AAFFAA"));  

2. Combined style (e.g. foreground and background) In this case case, you could use style chaining like this:

Style chainedStyle = new Style()   // Create a new (blank) style...
                .Append(Style.BasicStyles.ColorizedText("FF00FF"))   // ... and append part 
                .Append(Style.BasicStyles.ColorizedBackground("AAFFAA"));   // ... and append another part 
workbook.WS.Value("test", chainedStyle );

Keep in mind that the first three lines of this code are one single function call (could be on one line)

Can you try this out or provide me the relevant code?

Thank you in advance.

rabanti-github commented 6 years ago

The bug was fixed with commit 3d88769. The NuGet package is up to date and should be available in a few minutes (v2.5.1)

Thank you for the report. Please test the functionality and repoen the issue if somethin is not working as expected.

Greetings.

visualczm commented 6 years ago

good job.