protected void btnConfirg_Click(object sender, EventArgs e)
{
genExcel(); } //设置内容文字色 表中有一个蓝色文字列和绿色文字列
protected Aspose.Cells.Style get_content_style(Workbook workbook, Color clrmy)
{
Aspose.Cells.Style styleTitleBlue = workbook.Styles[workbook.Styles.Add()];
styleTitleBlue.HorizontalAlignment = TextAlignmentType.Center;
styleTitleBlue.Font.Name = "Arial";
styleTitleBlue.Font.Size = 11;
styleTitleBlue.IsTextWrapped = true;
styleTitleBlue.Font.Color = clrmy;
return styleTitleBlue;
} //一般标题样式
protected Aspose.Cells.Style get_title_style(Workbook workbook, Color clrmy)
{
Aspose.Cells.Style styleTitle = workbook.Styles[workbook.Styles.Add()];
styleTitle.HorizontalAlignment = TextAlignmentType.Center; //标题居中对齐
styleTitle.VerticalAlignment = TextAlignmentType.Bottom; //垂直底对齐
styleTitle.Font.Name = "Arial"; //字体
styleTitle.Font.Size = 11; //字体大小
styleTitle.IsTextWrapped = true; //自动换行
styleTitle.Font.Color = clrmy;
return styleTitle;
}
//------------------------------------------------------------------------
// 工作表标题行,第一行样式
//------------------------------------------------------------------------
protected Aspose.Cells.Style set_title_style(Workbook workbook, TextAlignmentType aliCenter)
{
Aspose.Cells.Style style_top = workbook.Styles[workbook.Styles.Add()];
style_top.HorizontalAlignment = aliCenter; //标题居中对齐
style_top.Font.Size = 18; //字体大小
style_top.Font.Color = System.Drawing.Color.Blue;
style_top.Font.IsBold = true;
return style_top;
} protected void genExcel()
{
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells; //居中对齐样式
Aspose.Cells.Style style_H_c = workbook.Styles[workbook.Styles.Add()];
style_H_c.HorizontalAlignment = TextAlignmentType.Center; //标题居中对齐 //------------------------------------------------------------------------
// 字段表头黄背前红标题样式
//------------------------------------------------------------------------
Aspose.Cells.Style styleTitleYR = workbook.Styles[workbook.Styles.Add()];
styleTitleYR.HorizontalAlignment = TextAlignmentType.Center;
styleTitleYR.VerticalAlignment = TextAlignmentType.Bottom;
styleTitleYR.Font.Name = "Arial";
styleTitleYR.Font.IsBold = true; //加粗
styleTitleYR.Font.Size = 11;
styleTitleYR.IsTextWrapped = true;
styleTitleYR.Font.Color = Color.Red; //字色为红
styleTitleYR.ForegroundColor = Color.FromArgb(255, 255, 153); ;// Color.Yellow;
styleTitleYR.Pattern = BackgroundType.Solid;
//------------------------------------------------------------------------
// 字段内容黄背前红标题样式
//------------------------------------------------------------------------
Aspose.Cells.Style styleTitleYR_nr = workbook.Styles[workbook.Styles.Add()];
styleTitleYR_nr.HorizontalAlignment = TextAlignmentType.Center;
styleTitleYR_nr.Font.Name = "Arial";
styleTitleYR_nr.Font.Size = 11;
styleTitleYR_nr.IsTextWrapped = true;
styleTitleYR_nr.Font.Color = Color.Black;
styleTitleYR_nr.ForegroundColor = Color.FromArgb(255, 255, 153);//Color.Yellow;
styleTitleYR_nr.Pattern = BackgroundType.Solid; //行高列宽设置-------------------------------------
cells.SetRowHeight(0, 23.25);
cells.SetRowHeight(1, 45);
cells.SetColumnWidth(0, 16.29);
cells.SetColumnWidth(1, 10.43);
cells.SetColumnWidth(2, 28.43);
cells.SetColumnWidth(3, 7);
cells.SetColumnWidth(4, 9.43);
cells.SetColumnWidth(5, 17.71);
cells.SetColumnWidth(6, 18);
cells.SetColumnWidth(7, 7.86);
cells.SetColumnWidth(8, 15.43);
cells.SetColumnWidth(9, 15.43);
cells.SetColumnWidth(10, 13.43);
cells.SetColumnWidth(11, 43.71);
cells.SetColumnWidth(12, 15.29);
cells.SetColumnWidth(13, 28.86);
cells.SetColumnWidth(14, 13.57);
cells.SetColumnWidth(15, 17.43);
cells.SetColumnWidth(16, 15.14);
cells.SetColumnWidth(17, 6.57);
cells.SetColumnWidth(18, 18.14); //表头样式设置-------------------------------------
cells[0, 0].PutValue("Yellow column filled by garment factory");
cells[0, 0].SetStyle(set_title_style(workbook, TextAlignmentType.Left));
cells[0, 5].PutValue("Date");
cells[0, 5].SetStyle(set_title_style(workbook, TextAlignmentType.Center));
cells[0, 6].PutValue("10/20/2013");
cells[0, 6].SetStyle(set_title_style(workbook, TextAlignmentType.Center)); cells[1, 0].PutValue("Garment Style");
cells[1, 0].SetStyle(styleTitleYR);
cells[1, 12].SetStyle(styleTitleYR);
cells[1, 12].PutValue("Handover date");
cells[1, 13].SetStyle(styleTitleYR);
cells[1, 13].PutValue("ship mode");
cells[1, 14].SetStyle(styleTitleYR);
cells[1, 14].PutValue("ship mode cfm by");
cells[1, 15].SetStyle(styleTitleYR);
cells[1, 15].PutValue("AIR APPD BY (PRODUCTION TEAM)");
cells[1, 1].PutValue("Factory#");
cells[1, 2].PutValue("GV PO");
cells[1, 3].PutValue("Supplier#");
cells[1, 4].PutValue("Supplier PI#");
cells[1, 5].PutValue("Trims ref#");
cells[1, 6].PutValue("Color-Size");
cells[1, 7].PutValue("Qty#");
cells[1, 8].PutValue("Read date");
cells[1, 9].PutValue("P/I Confirm Date");
cells[1, 10].PutValue("Remarks");
cells[1, 11].PutValue("Estimate Weight(kgs)");
cells[1, 16].PutValue("Our Ref No.");
cells[1, 17].PutValue("Index");
cells[1, 18].PutValue("Wight"); Range title_normal = sheet.Cells.CreateRange(1, 1, 1, 11); //普通表头标题
title_normal.SetStyle(get_title_style(workbook, Color.Black)); Range title_normal_end = sheet.Cells.CreateRange(1, 16, 1, 3); //普通表头标题
title_normal_end.SetStyle(get_title_style(workbook, Color.Black)); Range title_content_b = sheet.Cells.CreateRange(2, 8, 65535, 1); //蓝色内容
title_content_b.SetStyle(get_content_style(workbook, Color.Blue)); //styleTitleBlue); Range title_contne_g = sheet.Cells.CreateRange(2, 10, 65535, 1); //绿色内容
title_contne_g.SetStyle(get_content_style(workbook, Color.Green)); //styleTitleGreen); cells[1, 10].SetStyle(get_title_style(workbook, Color.Green));
cells[1, 8].SetStyle(get_title_style(workbook, Color.Blue)); //列背景色设置--------------------------------------
Range range = sheet.Cells.CreateRange(2, 0, 65535, 1);
Range range1 = sheet.Cells.CreateRange(2, 12, 65535, 4); range.SetStyle(styleTitleYR_nr);
range1.SetStyle(styleTitleYR_nr);
//内容设置------------------------------------------ for (int i = 0; i < 10; i++)
{
cells[i + 2, 1].PutValue(i.ToString(),true);
cells[i + 2, 2].PutValue(i.ToString(), true);
cells[i + 2, 3].PutValue(i.ToString(), true);
cells[i + 2, 4].PutValue(i.ToString(), true);
cells[i + 2, 5].PutValue(i.ToString(), true);
cells[i + 2, 7].PutValue(i.ToString(), true);
cells[i + 2, 11].PutValue(i.ToString(), true);
cells[i + 2, 16].PutValue(i.ToString(), true);
cells[i + 2, 17].PutValue((i + 1).ToString(), true);
cells[i + 2, 18].PutValue(i.ToString(), true); cells[i + 2, 1].SetStyle(style_H_c);
cells[i + 2, 2].SetStyle(style_H_c);
cells[i + 2, 3].SetStyle(style_H_c);
cells[i + 2, 4].SetStyle(style_H_c);
cells[i + 2, 5].SetStyle(style_H_c);
cells[i + 2, 7].SetStyle(style_H_c);
cells[i + 2, 11].SetStyle(style_H_c);
cells[i + 2, 16].SetStyle(style_H_c);
cells[i + 2, 17].SetStyle(style_H_c);
cells[i + 2, 18].SetStyle(style_H_c);
} System.IO.MemoryStream ms = workbook.SaveToStream();
byte[] bt = ms.ToArray();
workbook.Save(@"d:\test.xls");
}

下载Aspose.ddl

关于Aspose强大的应用--EXECL的更多相关文章

  1. Aspose 强大的服务器端 excel word ppt pdf 处理工具

    Aspose 强大的服务器端 excel word ppt pdf 处理工具 http://www.aspose.com/java/word-component.aspx

  2. Aspose.Cells.dll操作execl

    附件:Aspose.Cells.dll 1.创建execl(不需要服务器或者客户端安装office) public void DCExexl(DataTable dt) {  Workbook wb ...

  3. Aspose.Cells导入导出execl

    插件:Aspose.Cells 没有安装office插件也能使用: 导出:不能使用ajax异步· /// <summary> /// 导出试题 /// </summary> / ...

  4. 数据字典生成工具之旅(4):NPOI操作EXECL

    这篇会介绍NPOI读写EXECL,读写EXECL的组件很多,可以使用微软自己的COM组件EXECL.exe读写,不过这种方式限制很大. 1:客户环境必须装Office(虽然现在机子上不装Office的 ...

  5. Aspose是一个很强大的控件,可以用来操作word,excel,ppt等文件

    Aspose是一个很强大的控件,可以用来操作word,excel,ppt等文件,用这个控件来导入.导出数据非常方便.其中Aspose.Cells就是用来操作Excel的,功能有很多.我所用的是最基本的 ...

  6. 免费公开课,讲解强大的文档集成组件Aspose,现在可报名

    课程①:Aspose.Total公开课内容:讲解全能型文档管理工具Aspose.Total主要功能及应用领域时间:2016-11-24 14:30 (暂定)报名地址:http://training.e ...

  7. 【原创】Aspose.Words组件介绍及使用—基本介绍与DOM概述

           本博客所有文章分类的总目录:http://www.cnblogs.com/asxinyu/p/4288836.html 本博客其他.NET开源项目文章目录:http://www.cnbl ...

  8. 利用Aspose.Word控件和Aspose.Cell控件,实现Word文档和Excel文档的模板化导出

    我们知道,一般都导出的Word文档或者Excel文档,基本上分为两类,一类是动态生成全部文档的内容方式,一种是基于固定模板化的内容输出,后者在很多场合用的比较多,这也是企业报表规范化的一个体现. 我的 ...

  9. 【转】Aspose.Cells读取excel文件

    Aspose是一个很强大的控件,可以用来操作word,excel,ppt等文件,用这个控件来导入.导出数据非常方便.其中Aspose.Cells就是用来操作Excel的,功能有很多.我所用的是最基本的 ...

随机推荐

  1. ejs和swig对比的问题之一

    本来想测试下两者在nodejs中得执行速度,设置了一个测试数据,如下 var testData = { title:'测试标题', description: '<p>这是一个描述,里面用很 ...

  2. java实现顺序链表

    C&C++是那么难学,以至于我连指针是什么都不知道.所以只能学习java了. 如今想用java实现N年前学过“数据结构(c语言版)”却又是那么吃力! 慢慢练吧! 写此博客,仅标记自己学过数据结 ...

  3. HTML5 <input> required

    要求在提交数据之前必须填写该字段,否则会提交不了   <form>          <input type="text" id="msg" ...

  4. wap、app移动端页面常用html标签汇总

    1.section 将内容组织到精确的语义块,表示页面的一部分. 2.article article表示网页的一个文章.故事. 3.header (1)用在整页的页头 (2)section或者arti ...

  5. Sublime Text 包管理工具及扩展大全

    Sublime Text 是程序员们公认的编码神奇,拥有漂亮的用户界面和强大的功能,例如代码缩略图,多重选择,快捷命令等.还可自定义键绑定,菜单和工具栏.Sublime Text 的主要功能包括:拼写 ...

  6. oracle 存储过程 返回结果集

      oracle 存储过程 返回结果集 CreationTime--2018年8月14日09点50分 Author:Marydon 1.情景展示 oracle存储过程如何返回结果集 2.解决方案 最简 ...

  7. 33、深入理解Java的接口和抽象类

    深入理解Java的接口和抽象类 对于面向对象编程来说,抽象是它的一大特征之一.在Java中,可以通过两种形式来体现OOP的抽象:接口和抽象类.这两者有太多相似的地方,又有太多不同的地方.很多人在初学的 ...

  8. vcs github gitlab git名词解释

    vcs:version control system git:一个版本管理工具,从git上clone,除了代码,还会把版本信息也给你clone下来. github:一个基于git的代码管理网站,支持公 ...

  9. Apache Ant和Apache Maven的区别

    Apache Ant和Apache Maven的区别 分类: ANT Maven 2013-12-10 18:47 1477人阅读 评论(26) 收藏 举报 ———摘自<maven权威指南> ...

  10. 【转帖】基于Zookeeper的服务注册与发现

    http://www.techweb.com.cn/network/hardware/2015-12-25/2246973.shtml 背景 大多数系统都是从一个单一系统开始起步的,随着公司业务的快速 ...