br.com.tecsinapse.exporter.style.CssStyle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tecsinapse-data-io Show documentation
Show all versions of tecsinapse-data-io Show documentation
A simple way to work with CSV, XLSX? and TXT files
/*
* Tecsinapse Data Input and Output
*
* License: GNU Lesser General Public License (LGPL), version 3 or later
* See the LICENSE file in the root directory or .
*/
package br.com.tecsinapse.exporter.style;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.HSSFColor.WHITE;
public enum CssStyle {
BOLD("font-weight:bold;"),
ITALIC("font-style:italic;"),
UNDERLINE("text-decoration:underline;"),
STRIKEOUT("text-decoration:line-through;");
private final String css;
CssStyle(String css) {
this.css = css;
}
public String getCss() {
return css;
}
public static String toBackgroundColor(HSSFColor hssfColor) {
return toBackgroundColor(hssfColor, false);
}
public static String toBackgroundColor(HSSFColor hssfColor, boolean whiteAsTransparent) {
if (hssfColor == null) {
return "";
}
if (whiteAsTransparent && WHITE.hexString.equals(hssfColor.getHexString())) {
return "";
}
return String.format("background-color:%s;", StyleColorUtil.toHexColor(hssfColor));
}
public static String toTextColor(HSSFColor hssfColor) {
if (hssfColor == null) {
return "";
}
return String.format("color:%s;", StyleColorUtil.toHexColor(hssfColor));
}
public static String toFontSize(int fontSize) {
return String.format("font-size:%d;", fontSize);
}
}