using System;
using System.IO;
using System.Windows.Forms;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel; namespace App1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
string fileName = Path.Combine(Application.StartupPath, "Color Report (Beta).xls");
HSSFWorkbook book = new HSSFWorkbook(); ISheet sheet = book.CreateSheet("Color Detail"); ICellStyle style = book.CreateCellStyle();
style.FillPattern = FillPattern.SolidForeground;
style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Aqua.Index;
sheet.CreateRow().CreateCell().CellStyle = style; ICellStyle style1 = book.CreateCellStyle();
style1.CloneStyleFrom(style);
style1.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Automatic.Index;
sheet.CreateRow().CreateCell().CellStyle = style1; ICellStyle style2 = book.CreateCellStyle();
style2.CloneStyleFrom(style);
style2.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Black.Index;
sheet.CreateRow().CreateCell().CellStyle = style2; ICellStyle style3 = book.CreateCellStyle();
style3.CloneStyleFrom(style);
style3.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Blue.Index;
sheet.CreateRow().CreateCell().CellStyle = style3; ICellStyle style4 = book.CreateCellStyle();
style4.CloneStyleFrom(style);
style4.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.BlueGrey.Index;
sheet.CreateRow().CreateCell().CellStyle = style4; ICellStyle style5 = book.CreateCellStyle();
style5.CloneStyleFrom(style);
style5.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.BrightGreen.Index;
sheet.CreateRow().CreateCell().CellStyle = style5; ICellStyle style6 = book.CreateCellStyle();
style6.CloneStyleFrom(style);
style6.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Brown.Index;
sheet.CreateRow().CreateCell().CellStyle = style6; ICellStyle style7 = book.CreateCellStyle();
style7.CloneStyleFrom(style);
style7.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Coral.Index;
sheet.CreateRow().CreateCell().CellStyle = style7; ICellStyle style8 = book.CreateCellStyle();
style8.CloneStyleFrom(style);
style8.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.CornflowerBlue.Index;
sheet.CreateRow().CreateCell().CellStyle = style8; ICellStyle style9 = book.CreateCellStyle();
style9.CloneStyleFrom(style);
style9.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.DarkBlue.Index;
sheet.CreateRow().CreateCell().CellStyle = style9; ICellStyle style10 = book.CreateCellStyle();
style10.CloneStyleFrom(style);
style10.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.DarkGreen.Index;
sheet.CreateRow().CreateCell().CellStyle = style10; ICellStyle style11 = book.CreateCellStyle();
style11.CloneStyleFrom(style);
style11.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.DarkRed.Index;
sheet.CreateRow().CreateCell().CellStyle = style11; ICellStyle style12 = book.CreateCellStyle();
style12.CloneStyleFrom(style);
style12.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.DarkTeal.Index;
sheet.CreateRow().CreateCell().CellStyle = style12; ICellStyle style13 = book.CreateCellStyle();
style13.CloneStyleFrom(style);
style13.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.DarkYellow.Index;
sheet.CreateRow().CreateCell().CellStyle = style13; ICellStyle style14 = book.CreateCellStyle();
style14.CloneStyleFrom(style);
style14.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Gold.Index;
sheet.CreateRow().CreateCell().CellStyle = style14; ICellStyle style15 = book.CreateCellStyle();
style15.CloneStyleFrom(style);
style15.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Green.Index;
sheet.CreateRow().CreateCell().CellStyle = style15; ICellStyle style16 = book.CreateCellStyle();
style16.CloneStyleFrom(style);
style16.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey25Percent.Index;
sheet.CreateRow().CreateCell().CellStyle = style16; ICellStyle style17 = book.CreateCellStyle();
style17.CloneStyleFrom(style);
style17.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey40Percent.Index;
sheet.CreateRow().CreateCell().CellStyle = style17; ICellStyle style18 = book.CreateCellStyle();
style18.CloneStyleFrom(style);
style18.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey50Percent.Index;
sheet.CreateRow().CreateCell().CellStyle = style18; ICellStyle style19 = book.CreateCellStyle();
style19.CloneStyleFrom(style);
style19.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey80Percent.Index;
sheet.CreateRow().CreateCell().CellStyle = style19; ICellStyle style20 = book.CreateCellStyle();
style20.CloneStyleFrom(style);
style20.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Indigo.Index;
sheet.CreateRow().CreateCell().CellStyle = style20; ICellStyle style21 = book.CreateCellStyle();
style21.CloneStyleFrom(style);
style21.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Lavender.Index;
sheet.CreateRow().CreateCell().CellStyle = style21; ICellStyle style22 = book.CreateCellStyle();
style22.CloneStyleFrom(style);
style22.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LemonChiffon.Index;
sheet.CreateRow().CreateCell().CellStyle = style22; ICellStyle style23 = book.CreateCellStyle();
style23.CloneStyleFrom(style);
style23.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightBlue.Index;
sheet.CreateRow().CreateCell().CellStyle = style23; ICellStyle style24 = book.CreateCellStyle();
style24.CloneStyleFrom(style);
style24.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightCornflowerBlue.Index;
sheet.CreateRow().CreateCell().CellStyle = style24; ICellStyle style25 = book.CreateCellStyle();
style25.CloneStyleFrom(style);
style25.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightGreen.Index;
sheet.CreateRow().CreateCell().CellStyle = style25; ICellStyle style26 = book.CreateCellStyle();
style26.CloneStyleFrom(style);
style26.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightOrange.Index;
sheet.CreateRow().CreateCell().CellStyle = style26; ICellStyle style27 = book.CreateCellStyle();
style27.CloneStyleFrom(style);
style27.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightTurquoise.Index;
sheet.CreateRow().CreateCell().CellStyle = style27; ICellStyle style28 = book.CreateCellStyle();
style28.CloneStyleFrom(style);
style28.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightYellow.Index;
sheet.CreateRow().CreateCell().CellStyle = style28; ICellStyle style29 = book.CreateCellStyle();
style29.CloneStyleFrom(style);
style29.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Lime.Index;
sheet.CreateRow().CreateCell().CellStyle = style29; ICellStyle style30 = book.CreateCellStyle();
style30.CloneStyleFrom(style);
style30.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Maroon.Index;
sheet.CreateRow().CreateCell().CellStyle = style30; ICellStyle style31 = book.CreateCellStyle();
style31.CloneStyleFrom(style);
style31.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.OliveGreen.Index;
sheet.CreateRow().CreateCell().CellStyle = style31; ICellStyle style32 = book.CreateCellStyle();
style32.CloneStyleFrom(style);
style32.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Orange.Index;
sheet.CreateRow().CreateCell().CellStyle = style32; ICellStyle style33 = book.CreateCellStyle();
style33.CloneStyleFrom(style);
style33.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Orchid.Index;
sheet.CreateRow().CreateCell().CellStyle = style33; ICellStyle style34 = book.CreateCellStyle();
style34.CloneStyleFrom(style);
style34.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.PaleBlue.Index;
sheet.CreateRow().CreateCell().CellStyle = style34; ICellStyle style35 = book.CreateCellStyle();
style35.CloneStyleFrom(style);
style35.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Pink.Index;
sheet.CreateRow().CreateCell().CellStyle = style35; ICellStyle style36= book.CreateCellStyle();
style36.CloneStyleFrom(style);
style36.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Plum.Index;
sheet.CreateRow().CreateCell().CellStyle = style36; ICellStyle style37 = book.CreateCellStyle();
style37.CloneStyleFrom(style);
style37.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Red.Index;
sheet.CreateRow().CreateCell().CellStyle = style37; ICellStyle style38 = book.CreateCellStyle();
style38.CloneStyleFrom(style);
style38.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Rose.Index;
sheet.CreateRow().CreateCell().CellStyle = style38; ICellStyle style39 = book.CreateCellStyle();
style39.CloneStyleFrom(style);
style39.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.RoyalBlue.Index;
sheet.CreateRow().CreateCell().CellStyle = style39; ICellStyle style40 = book.CreateCellStyle();
style40.CloneStyleFrom(style);
style40.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.SeaGreen.Index;
sheet.CreateRow().CreateCell().CellStyle = style40; ICellStyle style41 = book.CreateCellStyle();
style41.CloneStyleFrom(style);
style41.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.SkyBlue.Index;
sheet.CreateRow().CreateCell().CellStyle = style41; ICellStyle style42 = book.CreateCellStyle();
style42.CloneStyleFrom(style);
style42.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Tan.Index;
sheet.CreateRow().CreateCell().CellStyle = style42; ICellStyle style43 = book.CreateCellStyle();
style43.CloneStyleFrom(style);
style43.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Teal.Index;
sheet.CreateRow().CreateCell().CellStyle = style43; ICellStyle style44 = book.CreateCellStyle();
style44.CloneStyleFrom(style);
style44.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Turquoise.Index;
sheet.CreateRow().CreateCell().CellStyle = style44; ICellStyle style45 = book.CreateCellStyle();
style45.CloneStyleFrom(style);
style45.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Violet.Index;
sheet.CreateRow().CreateCell().CellStyle = style45; ICellStyle style46 = book.CreateCellStyle();
style46.CloneStyleFrom(style);
style46.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.White.Index;
sheet.CreateRow().CreateCell().CellStyle = style46; ICellStyle style47 = book.CreateCellStyle();
style47.CloneStyleFrom(style);
style47.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
sheet.CreateRow().CreateCell().CellStyle = style47; ((HSSFSheet)book.GetSheetAt()).AlternativeFormula = false;
((HSSFSheet)book.GetSheetAt()).AlternativeExpression = false; //Write the stream data of workbook to the root directory
FileStream file = new FileStream(fileName, FileMode.Create);
book.Write(file);
file.Close();
}
}
}

HSSF NPOI 颜色的更多相关文章

  1. NPOI颜色对照表

    颜色对照表:颜色 测试 Class名称 short        Test颜色 Black 8 Test颜色 Brown 60 Test颜色 Olive_Green 59 Test颜色 Dark_Gr ...

  2. C# 如何使用NPOI操作Excel以及读取合并单元格等

    C#操作Excel方法有很多,以前用的需要电脑安装office才能用,但因为版权问题公司不允许安装office.所以改用NPOI进行Excel操作,基本上一些简单的Excel操作都没有问题,读写合并单 ...

  3. C#NPOI对Excel的操作、导入导出时异常处理、最全的NPOI资料在这里~

    一.Excel理论知识 最新版NPOI2.4.1链接:https://pan.baidu.com/s/1iTgJi2hGsRQHyw2S_4dIUw  提取码:adnq • 整个Excel表格叫做工作 ...

  4. 基于NPOI对Excel进行简单的操作

    1. 关于NPOI NPOI是一个开源的用于在C#程序中读写Excel.WORD等微软OLE2组件文档的项目,使用NPOI可以在没有安装Office的情况下对Word或Excel文档进行读写操作. 2 ...

  5. NPOI导Excel样式设置(转)

    一.创建一个Excel //创建一个工作簿 XSSFWorkbook workbook = new XSSFWorkbook(); //创建一个页 ISheet sheet = workbook.Cr ...

  6. NPOI导Excel样式设置

    一.创建一个Excel //创建一个工作簿 XSSFWorkbook workbook = new XSSFWorkbook(); //创建一个页 ISheet sheet = workbook.Cr ...

  7. NPOI 导出Excel 2007, 2013问题

    NPOI默认有两个命名空间HSSF为Excel 2003 版本,若导出2007 及以上后缀名打开excel 则会报错,NPOI也提供了一个07及以上的版本空间XSSF,具体操作列下: NPOI.XSS ...

  8. nopi excel 导入

    #region 从Excel导入 /// <summary> /// 读取excel ,默认第一行为标头 /// </summary> /// <param name=& ...

  9. asp.net core导出导入excel

    使用NPOI导入导出excel,已经封装好Action可以直接调用 导出 效果图 使用方法 定义导出实体 class Student { public int Id { get; set; } pub ...

随机推荐

  1. 用redis做简单的任务队列(一)

    队列本身其实是个有序的列表,而Redis是支持list的,我们可以查看Redis的官方文档 http://redis.io/commands#list,其中我们可以对这个队列的两端分别进行操作,所以其 ...

  2. L1-017 到底有多二

    一个整数“犯二的程度”定义为该数字中包含2的个数与其位数的比值.如果这个数是负数,则程度增加0.5倍:如果还是个偶数,则再增加1倍.例如数字-13142223336是个11位数,其中有3个2,并且是负 ...

  3. IIS7 经典模式和集成模式的区别

    IIS7.0中的Web应用程序有两种配置形式:经典形式和集成形式. 经典形式是为了与之前的版本兼容,运用ISAPI扩展来调用ASP.NET运转库,原先运转于IIS6.0下的Web应用程序迁移到IIS7 ...

  4. WebGL编程指南案例解析之纹理叠加

    var vShader = ` attribute vec4 a_Position; attribute vec2 a_TexCoord; varying vec2 v_TexCoord; void ...

  5. Ubuntu终端点击确定按钮的方法

    Ubuntu终端里出现需要点击 确定 按钮的时候,直接鼠标点击 确定 是不生效的,这个时候需要利用tab键选中这个 确定 按钮,然后回车键就可以了.

  6. css怎么让li水平排列和div居中

    让li向左浮动即可 给div定一个宽度,然后margin:0 auto;即可:

  7. 转:如何解决VC "应用程序无法启动,因为应用程序的并行配置不正确 sxstrace.exe"问题

    如何解决VC "应用程序无法启动,因为应用程序的并行配置不正确 sxstrace.exe"问题   引用链接 http://blog.csdn.net/pizi0475/artic ...

  8. php curl批处理

    php模拟多线程用到curl库,这个库很强大,可以做好多事,比如模拟登陆,文件上传/下载,数据采集等. 下面是我的代码,很简单,有些还功能还不会用. <?php $node_urls=array ...

  9. Sublime Text3 使用

    注: 1.绿色版的某些插件有问题,导致某些插件无法使用,而且无法删除和安装,需要删除Data/Cache目录,重新安装无法使用的插件 2.绿色版无法编译python,可使用安装版安装sublime后, ...

  10. Linux下rsync命令使用总结

    一.rsync的概述 rsync是类unix系统下的数据镜像备份工具,从软件的命名上就可以看出来了——remote sync.rsync是Linux系统下的文件同步和数据传输工具,它采用“rsync” ...