关于Aspose强大的应用--EXECL
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强大的应用--EXECL的更多相关文章
- Aspose 强大的服务器端 excel word ppt pdf 处理工具
Aspose 强大的服务器端 excel word ppt pdf 处理工具 http://www.aspose.com/java/word-component.aspx
- Aspose.Cells.dll操作execl
附件:Aspose.Cells.dll 1.创建execl(不需要服务器或者客户端安装office) public void DCExexl(DataTable dt) { Workbook wb ...
- Aspose.Cells导入导出execl
插件:Aspose.Cells 没有安装office插件也能使用: 导出:不能使用ajax异步· /// <summary> /// 导出试题 /// </summary> / ...
- 数据字典生成工具之旅(4):NPOI操作EXECL
这篇会介绍NPOI读写EXECL,读写EXECL的组件很多,可以使用微软自己的COM组件EXECL.exe读写,不过这种方式限制很大. 1:客户环境必须装Office(虽然现在机子上不装Office的 ...
- Aspose是一个很强大的控件,可以用来操作word,excel,ppt等文件
Aspose是一个很强大的控件,可以用来操作word,excel,ppt等文件,用这个控件来导入.导出数据非常方便.其中Aspose.Cells就是用来操作Excel的,功能有很多.我所用的是最基本的 ...
- 免费公开课,讲解强大的文档集成组件Aspose,现在可报名
课程①:Aspose.Total公开课内容:讲解全能型文档管理工具Aspose.Total主要功能及应用领域时间:2016-11-24 14:30 (暂定)报名地址:http://training.e ...
- 【原创】Aspose.Words组件介绍及使用—基本介绍与DOM概述
本博客所有文章分类的总目录:http://www.cnblogs.com/asxinyu/p/4288836.html 本博客其他.NET开源项目文章目录:http://www.cnbl ...
- 利用Aspose.Word控件和Aspose.Cell控件,实现Word文档和Excel文档的模板化导出
我们知道,一般都导出的Word文档或者Excel文档,基本上分为两类,一类是动态生成全部文档的内容方式,一种是基于固定模板化的内容输出,后者在很多场合用的比较多,这也是企业报表规范化的一个体现. 我的 ...
- 【转】Aspose.Cells读取excel文件
Aspose是一个很强大的控件,可以用来操作word,excel,ppt等文件,用这个控件来导入.导出数据非常方便.其中Aspose.Cells就是用来操作Excel的,功能有很多.我所用的是最基本的 ...
随机推荐
- OpenVPN多处理之-为什么不
OpenVPN没有多处理.人所皆知.我觉得我有点啰嗦了.天天说这个事.为什么没有多处理呢?我们来看下OpenVPN的作者,大牛级别的,早已超越代码的重量级人物,James Yonan(简称JY)是怎么 ...
- SpringMVC日期类型转换问题处理方法归纳
前言 我们在SpringMVC开发中,可能遇到比较多的问题就是前台与后 台实体类之间日期转换处理的问题了,说问题也不大,但很多人开发中经常会遇到这个问题,有时很令人头疼,有时间问题暴露的不是很明显,然 ...
- struts脚本调用action,页面第一次访问不调用
result type 如果是默认 第一次访问页面不会访问action,刷新才会请求 type=redirect 第一次访问会直接访问action 或者在调用地址加 url?+随机数
- 微信群的id
今天网速慢了,竟然把微信群的id卡出来了,记录一下. 格式应该是一个像QQ群一样的数字,然后+@chatroom 看图! 文章来源:刘俊涛的博客 欢迎关注,有问题一起学习欢迎留言.评论.
- java在线预览txt、word、ppt、execel,pdf代码
在页面上显示各种文档中的内容.在servlet中的逻辑 word: BufferedInputStream bis = null; URL url = null; HttpURLConnection ...
- 每日一Vim(1)
来自 上一篇讲过了Vim的基本操作命令(打开,编辑,保存退出)以及Vim的三种基本模式和光标的基本导航(hjkl),今天讲一些稍微高级点的光标移动,以及一些基本的文本操作命令. 翻一页/半页 对于一个 ...
- 安装SQL SERVER 2016 CTP (二)[多图]
内容中包含 base64string 图片造成字符过多,拒绝显示
- 【UNIX网络编程】FIFO
管道作为进程间通信的最古老方式,它的缺点是没有名字,因此仅仅能用在有亲缘关系的父子进程之间.对于无亲缘关系的进程间.无法用管道进行通信.FIFO能够完毕无亲缘关系的进程间的通信.FIFO也被称为命名管 ...
- potplayer 网页调用potplayer播放本地视频
网页调用potplayer播放本地视频 CreateTime--2018年1月3日10:36:24 Author:Marydon 源码展示: <!DOCTYPE html> <h ...
- 〖Qt编程〗Qt编程中的各种数据类型的相互转换
char * 与 const char *的转换 char *ch1=”hello11″; const char *ch2=”hello22″; ch2 = ch1;//不报错,但有警告 ch1 = ...