在JExcelApi中制作新颜色 [英] Making new colors in JExcelApi

查看:237
本文介绍了在JExcelApi中制作新颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JExcelApi来生成XLS文件。从 jxl.format.Colour ,我看到如何获取标准Excel调色板中的任何颜色,但不能如何创建一个新的颜色(例如,给定其RGB)。



但是在Excel本身,我可以选择任何颜色。



我刚刚错过了吗?在JExcelApi中有没有办法选择任意颜色?我现在使用一个简单的find-the-standard-standard-color方法,这是可以的,但不是很好。

解决方案

2007年之前的Excel版本有一个标准调色板,并且鉴于您使用的API不支持2007格式,您可能会遇到这种情况。您可以选择所需颜色的原因可能是因为您正在使用新版本的Excel。



请参阅这个Microsoft网站上的信息



我看不到如何覆盖标准您正在使用的API中的调色板,但是在Apache POI(也可以让您编写Excel文件)中,您可以:参见此链接。基本上,您需要做的是:将一些标准颜色(绿色等)分配给您的单元格;然后使用您需要的任何自定义颜色 覆盖 这些颜色。


I'm using JExcelApi for generating XLS files. From jxl.format.Colour, I see how to get any of the colors in the "standard Excel colour palette", but not how to create a new color (say, given its RGB).

But in Excel itself, I can pick any color at all.

Am I just missing it? Is there a way in JExcelApi to select an arbitrary color? I'm using a simple find-the-closest-standard-color method right now, which is OK but not great.

解决方案

Excel versions before 2007 have a standard palette, and given that the API you are using does not support the 2007 format, you may be stuck with that. The reason you can choose any colour you want is probably because you are using a new version of Excel.

See this information on the Microsoft site.

I don't see how you could override the standard colour palette in the API you are using, but in Apache POI (which also lets you write Excel files) you can: see this link. Basically, what you need to do there is: assign certain standard colours (green, etc) to your cells; then override these colours with whatever custom colour you need.

这篇关于在JExcelApi中制作新颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆