跳转到路径导航栏
跳转到正文内容

利用 owc 生成 excel 并且显示在页面

http://www.sina.com.cn  2008年07月11日 13:06  IT168.com
   SpreadsheetClass xlsheet = new SpreadsheetClass();
设置标题#region  设置标题
//写标题
//合并单元格
            xlsheet.get_Range(xlsheet.Cells[1, 1], xlsheet.Cells[1,30]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[1, 1] = "采购执行情况一览表";
//字体加粗
            xlsheet.get_Range(xlsheet.Cells[1, 1], xlsheet.Cells[1, 30]).Font.set_Bold(true);
//单元格文本水平居中对齐
            xlsheet.get_Range(xlsheet.Cells[1, 1], xlsheet.Cells[1, 30]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
//设置字体大小
            xlsheet.get_Range(xlsheet.Cells[1, 1], xlsheet.Cells[1,30]).Font.set_Size(14);
#endregion
设置列#region  设置列
xlsheet.get_Range(xlsheet.Cells[2,1],xlsheet.Cells[3,1]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 1] = "序号";
xlsheet.get_Range(xlsheet.Cells[2, 1], xlsheet.Cells[3,1]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 2], xlsheet.Cells[3, 2]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 2] = "项目号";
xlsheet.get_Range(xlsheet.Cells[2, 2], xlsheet.Cells[3, 2]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 3], xlsheet.Cells[3, 3]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 3] = "包号";
xlsheet.get_Range(xlsheet.Cells[2, 3], xlsheet.Cells[3, 3]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 4], xlsheet.Cells[3, 4]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 4] = "包预算";
xlsheet.get_Range(xlsheet.Cells[2, 4], xlsheet.Cells[3, 4]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 5], xlsheet.Cells[3, 5]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 5] = "包计划请购日期";
xlsheet.get_Range(xlsheet.Cells[2, 5], xlsheet.Cells[3, 5]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 6], xlsheet.Cells[3, 6]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 6] = "包计划签约日期";
xlsheet.get_Range(xlsheet.Cells[2, 6], xlsheet.Cells[3,6]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 7], xlsheet.Cells[3, 7]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 7] = "包计划运输日期";
xlsheet.get_Range(xlsheet.Cells[2, 7], xlsheet.Cells[3, 7]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 8], xlsheet.Cells[3, 8]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 8] = "包计划检验日期";
xlsheet.get_Range(xlsheet.Cells[2, 8], xlsheet.Cells[3, 8]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 9], xlsheet.Cells[3, 9]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 9] = "项目经理";
xlsheet.get_Range(xlsheet.Cells[2, 9], xlsheet.Cells[3, 9]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 10], xlsheet.Cells[3, 10]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2,10] = "采购经理";
xlsheet.get_Range(xlsheet.Cells[2, 10], xlsheet.Cells[3, 10]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 11], xlsheet.Cells[3, 11]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 11] = "采购工程师";
xlsheet.get_Range(xlsheet.Cells[2, 11], xlsheet.Cells[3, 11]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);
xlsheet.get_Range(xlsheet.Cells[2, 12], xlsheet.Cells[3, 12]).set_MergeCells(true);
xlsheet.ActiveSheet.Cells[2, 12] = "包状态";
xlsheet.get_Range(xlsheet.Cells[2, 12], xlsheet.Cells[3, 12]).set_HorizontalAlignment(XlHAlign.xlHAlignCenter);

上一页 1 2 3 下一页

已有_COUNT_位网友发表评论  我要评论

Powered By Google ‘我的2008’,中国有我一份力!
·城市对话改革30年 ·新浪城市同心联动 ·诚招合作伙伴 ·企业邮箱畅通无阻

新浪简介About Sina广告服务联系我们招聘信息网站律师SINA English会员注册产品答疑┊Copyright © 1996-2008 SINA Corporation, All Rights Reserved

新浪公司 版权所有