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. Android常用到的一些事件

    1:查看是否有存储卡插入 String status=Environment.getExternalStorageState(); if(status.equals(Enviroment.MEDIA_ ...

  2. Oracle 之 常用函数

    SQL语句根据参数的不同,分为单行函数 和 多行函数. [1] 单行函数:输入是一行,输出也是一行: [2] 多行函数:输入多行数据,输出一个结果. 在执行时,单行函数是检索一行处理一次,而多行函数是 ...

  3. Eclipse自动编译NDK/JNI的三种方法

    一.Eclipse关联cygwin 1. 工程->右击选择Properties->选择Builders,在Builders中选择New创建一个Program 2. 参数配置 二.Eclip ...

  4. UVA - 10162 Last Digit

    Description  Problem B.Last Digit  Background Give you a integer number N (1<=n<=2*10100). Ple ...

  5. 使用PyQt4 designer时无法启动uic解决方案

    1.自己调用命令行 pyuic4 -o codeFile.py -x yourUIfile.ui 2.写一个批处理,每次双击就行了,跟你的源文件放在同一文件夹下 import os for root, ...

  6. TP框架模板中IF Else 如何使用?

    TP框架模板中IF Else 如何使用? 截个图吧 如果效果出不来,一般就是条件写错了!!!

  7. Android 断点续传下载

    断点续传在面试中出现的概率还是比较大的,因为一般的应用都需要. 这个代码是从网上找来的,自己改了点东西,能跑通,但是这个代码并不是最优代码和设计.但是基本思路体现出来了,可以以这个为基础来进行修改.先 ...

  8. hdu 4494 Teamwork (可行流的最小流)

    去年通话邀请赛的B题,当时居然过的那么少...明明是一道非常裸的可行流最小流麽..仅仅要对每种人分别求一下可行最小流加起来就能够了.建图是对每一个点拆点,容量上下届都设为v[i],然后每一个点间能连边 ...

  9. window.onunload | window.onbeforeunload

    先引述一段jQuery 官方对于onunload的评述: The unload event is sent to the window element when the user navigates ...

  10. 摘:C/C++中时间类time.h

    摘要:本文从介绍基础概念入手,探讨了在C/C++中对日期和时间操作所用到的数据结构和函数,并对计时.时间的获取.时间的计算和显示格式等方面进行了阐述.本文还通过大量的实例向你展示了time.h头文件中 ...