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. openerp创建动态视图-fields_view_get

    openerp的视图结构是以XML的格式存放于ir.ui.view表中,属于静态格式,设计之后就固定, 但可以通过在model中重写fields_view_get函数,在视图加载时修改arch属性,动 ...

  2. chrome更改缓存位置

      更改chrome浏览器缓存位置 CreateTime--2017年7月20日08:33:14Author:Marydon 一.参考链接 http://jingyan.baidu.com/artic ...

  3. 【Oracle】新建用户,删除用户,授权

    一.创建用户 oracle内部有两个建好的用户:system和sys.用户可直接登录到system用户以创建其他用户,因为system具有创建别 的用户的 权限. 在安装oracle时,用户或系统管理 ...

  4. Google C++ Coding Style 学习笔记

    写在前面:最新公司马上就要开始开发一款视觉产品,工程量较大,且需要对客户提供可以二次开 发的SDK,整个项目用C++编写. 这就对代码质量提出了非常高的要求,同时,如何设计出优雅稳定的API也是相当大 ...

  5. jsp基本语法总结

    一,用jsp脚本元素调用java代码 1,jsp表达式的应用 jsp表达式将值直接插入到输出中: <%= Java Expression %>  代表一个值 隐式对象,在使用jsp表达式的 ...

  6. LeetCode-2: Add Two Numbers

    [Problem:2-Add Two Numbers] You are given two non-empty linked lists representing two non-negative i ...

  7. java工具类之按对象中某属性排序

    import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang ...

  8. Python操作redis字符串(String)详解 (三)

    # -*- coding: utf-8 -*- import redis #这个redis不能用,请根据自己的需要修改 r =redis.Redis(host=") 1.SET 命令用于设置 ...

  9. mybatis 映射器

    1 映射器 Mapper 是由java接口和 XML 文件共同组成.它的作用如下 1)定义参数类型 2)描述缓存 3)描述 SQL 语句 4)定义查询结果和POJO的映射关系 2 SqlSession ...

  10. rabbitMQ之安装和配置(一)

    前言 erlang是一门面向并发的编程语言,流行的消息队列rabbitMQ是基于erlang环境运行的: 下载安装erlang语言环境 源码安装 # 从官网下载,在任何目录下,使用root权限 wge ...