public void OutExcel()
{
#region
WorkbookDesigner designer = new WorkbookDesigner();
Worksheet sheet = designer.Workbook.Worksheets[];
Workbook book = designer.Workbook; Aspose.Cells.Style style1 = book.Styles[book.Styles.Add()];
style1.Font.Name = "黑体";//文字字体
style1.Font.Size = ;//文字大小 Aspose.Cells.Style style2 = book.Styles[book.Styles.Add()];
style2.HorizontalAlignment = TextAlignmentType.Center;
style2.Font.Name = "宋体";//文字字体
style2.Font.IsBold = true;//粗体
style2.Font.Size = ;//文字大小 style2.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
style2.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
style2.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
style2.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
style2.Borders[BorderType.TopBorder].Color = Color.Black;
style2.Borders[BorderType.BottomBorder].Color = Color.Black;
style2.Borders[BorderType.LeftBorder].Color = Color.Black;
style2.Borders[BorderType.RightBorder].Color = Color.Black; Aspose.Cells.Style style3 = book.Styles[book.Styles.Add()];
style3.HorizontalAlignment = TextAlignmentType.Center;
style3.Font.Name = "宋体";//文字字体
style3.Font.Size = ;//文字大小
style2.Font.IsBold = true;//粗体 Aspose.Cells.Style style4 = book.Styles[book.Styles.Add()];
style4.HorizontalAlignment = TextAlignmentType.Center;
// style4.Font.Name = "黑体";//文字字体 "Arial Rounded MT Bold";//
style4.Font.Size = ;//文字大小 Aspose.Cells.Style style5 = book.Styles[book.Styles.Add()];
style5.HorizontalAlignment = TextAlignmentType.Center;
style5.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
style5.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
style5.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
style5.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
style5.Borders[BorderType.TopBorder].Color = Color.Black;
style5.Borders[BorderType.BottomBorder].Color = Color.Black;
style5.Borders[BorderType.LeftBorder].Color = Color.Black;
style5.Borders[BorderType.RightBorder].Color = Color.Black; //Aspose.Cells.Style style6 = book.Styles[book.Styles.Add()];
//style6.ForegroundColor = Color.FromArgb(153, 204, 0);//设置背景色//#DCE6F1
//style6.Pattern = Aspose.Cells.BackgroundType.Solid; Aspose.Cells.Style style7 = book.Styles[book.Styles.Add()];
style7.HorizontalAlignment = TextAlignmentType.Center;
style7.Font.Name = "黑体";//文字字体
style7.Font.Size = ;//文字大小 var c21 = sheet.Cells[, ];
c21.PutValue("点位");
c21.SetStyle(style1); var mm=sheet.Cells[,];
mm.PutValue("中国1");
mm.SetStyle(style1); var nn = sheet.Cells[, ];
nn.PutValue("中国2");
nn.SetStyle(style1); Range ranget1 = sheet.Cells.CreateRange(, , , );
ranget1.Merge();
ranget1.RowHeight = ; Cells cells = sheet.Cells;
cells.SetColumnWidth(, );//设置列宽 var c22 = sheet.Cells[, ];
c22.PutValue("类型");
c22.SetStyle(style1); for (int i = ; i < ; i++)
{
var c23 = sheet.Cells[, i + ];
c23.PutValue(i + ); c23.SetStyle(style1);
}
sheet.Cells[, ].PutValue("最小值"); sheet.Cells[, ].SetStyle(style1);
sheet.Cells[, ].PutValue("最大值"); sheet.Cells[, ].SetStyle(style1);
sheet.Cells[, ].PutValue("平均值"); sheet.Cells[, ].SetStyle(style1); string year = "";
string month = "";
int rowcount = ; //添加样式
//sheet.Cells[m + t + 1, 33].SetStyle(style4);
//sheet.Cells[m + t + 1, 34].SetStyle(style4);
//sheet.Cells[m + t + 1, 35].SetStyle(style4);
//Range ranget = sheet.Cells.CreateRange(t + k + k, 0, 2, 1);//从第几行第几列到结束行结束列
//ranget.Merge(); //合并单元格 Range range5 = sheet.Cells.CreateRange(, , rowcount * + , );
Aspose.Cells.StyleFlag borderStyle = new Aspose.Cells.StyleFlag();
borderStyle.Borders = true; //启用Borders样式
borderStyle.HorizontalAlignment = true; //启用水平对齐样式
borderStyle.Font = false;//不使用配置的字体样式
range5.ApplyStyle(style5, borderStyle); var c11 = sheet.Cells[, ];
string BiaoTi = "**监测有限公司" + year + "年" + month + "月水质监测结果汇总表";
c11.PutValue(BiaoTi);
c11.SetStyle(style2); Range range = sheet.Cells.CreateRange(, , , );
// Cell cell = range[0, 0];
range.Merge(); //合并单元格
range.RowHeight = ; Range range2 = sheet.Cells.CreateRange(, , rowcount * + , );
range2.RowHeight = ;//设置行高 Range range3 = sheet.Cells.CreateRange(, , , );
range3.RowHeight = ;//设置行高 string XFilename = HttpUtility.UrlEncode("**环境" + year + "年" + month + "月水质监测汇总表.xls", Encoding.UTF8).ToString();
Aspose.Cells.SaveOptions ss = new XlsSaveOptions(SaveFormat.Excel97To2003); designer.Workbook.Save(this.Response, XFilename, ContentDisposition.Attachment, ss);
#endregion
}
  public static class SqlHelper
{
private static readonly string conStr = ConfigurationManager.ConnectionStrings["sql"].ConnectionString; public static int ExecuteNonQuery(string sql, CommandType cmdType, params SqlParameter[] pms)
{
using (SqlConnection con = new SqlConnection(conStr))
{
using (SqlCommand cmd = new SqlCommand(sql, con))
{
cmd.CommandType = cmdType;
if (pms != null)
{
cmd.Parameters.AddRange(pms);
}
con.Open();
return cmd.ExecuteNonQuery();
}
}
} public static object ExecuteScalar(string sql, CommandType cmdType, params SqlParameter[] pms)
{
using (SqlConnection con = new SqlConnection(conStr))
{
using (SqlCommand cmd = new SqlCommand(sql, con))
{
cmd.CommandType = cmdType;
if (pms != null)
{
cmd.Parameters.AddRange(pms);
}
con.Open();
return cmd.ExecuteScalar();
}
}
} public static SqlDataReader ExecuteReader(string sql, CommandType cmdType, params SqlParameter[] pms)
{
SqlConnection con = new SqlConnection(conStr);
try
{
using (SqlCommand cmd = new SqlCommand(sql, con))
{
cmd.CommandType = cmdType;
if (pms != null)
{
cmd.Parameters.AddRange(pms);
}
con.Open();
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return reader;
}
}
catch
{
con.Dispose();
throw;
}
} public static DataTable ExecuteDataTable(string sql, CommandType cmdType, params SqlParameter[] pms)
{
using (SqlDataAdapter sda = new SqlDataAdapter(sql, conStr))
{
DataTable dt = new DataTable(); sda.SelectCommand.CommandType = cmdType;
if (pms != null)
{
sda.SelectCommand.Parameters.AddRange(pms);
}
sda.Fill(dt);
return dt;
}
}
}

Aspose.Cells.dll的用法的更多相关文章

  1. C# WinForm 导出导入Excel/Doc 完整实例教程[使用Aspose.Cells.dll]

    [csharp] view plain copy 1.添加引用: Aspose.Cells.dll(我们就叫工具包吧,可以从网上下载.关于它的操作我在“Aspose.Cells操作说明 中文版 下载 ...

  2. C# WinForm使用Aspose.Cells.dll 导出导入Excel/Doc 完整实例教程

    1.添加引用: Aspose.Cells.dll(我们就叫工具包吧,可以从网上下载.关于它的操作我在“Aspose.Cells操作说明 中文版 下载 Aspose C# 导出Excel 实例”一文中的 ...

  3. Aspose.Cells.dll引用导入导出Excel

    Aspose.Cells 导入导出EXCEL 文章出处:http://hi.baidu.com/leilongbing/item/c11467e1819e5417595dd8c1 修改样式       ...

  4. Aspose.Cells.dll操作execl

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

  5. C# Aspose.Cells.dll Excel操作总结

    简介 Aspose.Cells是一款功能强大的 Excel 文档处理和转换控件,不依赖 Microsoft Excel 环境,支持所有 Excel 格式类型的操作. 下载 Aspose.Cells.d ...

  6. C# 读写Excel的一些方法,Aspose.Cells.dll

    需求:现有2个Excel,一个7000,一个20W,7000在20W是完全存在的.现要分离20W的,拆分成19W3和7000. 条件:两个Excel都有“登录名”,然后用“登录名”去关联2个Excel ...

  7. C# 利用Aspose.Cells .dll将本地excel文档转化成pdf(完美破解版 无水印 无中文乱码)

    Aspose.Cells .dll下载  http://pan.baidu.com/s/1slRENLF并引用 C#代码 using System; using System.Collections. ...

  8. ExportGrid Aspose.Cells.dll

    using Aspose.Cells; using Aspose.Words; using System; using System.Collections; using System.Collect ...

  9. Aspose Cells dll 实现数据简单下载

    Workbook workbook = new Workbook(); //工作簿                     Worksheet sheet = workbook.Worksheets[ ...

随机推荐

  1. iOS 开发多线程 —— GCD(1)

    本文是根据文顶顶老师的博客学习总结而来,如有不妥之处,还望指出.http://www.cnblogs.com/wendingding/p/3807716.html 概览: /* 纯c语言,提供了非常多 ...

  2. 【Redis】Redis学习(四) Redis Sentinel模式详解

    主从模式的弊端就是不具备高可用性,当master挂掉以后,Redis将不能再对外提供写入操作,因此sentinel应运而生. Redis Sentinel是Redis官方提供的集群管理工具,主要有三大 ...

  3. Expo大作战(十一)--expo中的预加载和缓存资产(Preloading & Caching Assets),expo中的图标 (Icon)

    简要:本系列文章讲会对expo进行全面的介绍,本人从2017年6月份接触expo以来,对expo的研究断断续续,一路走来将近10个月,废话不多说,接下来你看到内容,讲全部来与官网 我猜去全部机翻+个人 ...

  4. 谨慎使用MyBatis自动生成Where语句

    最近监控到类似这样一个慢查询: select XX_time from XXOrderInfo WHERE ( OrderId is not null and OrderId = N'xxxx') x ...

  5. http的断点续传

    要实现断点续传的功能,通常都需要客户端记录下当前的下载进度,并在需要续传的时候通知服务端本次需要下载的内容片段. HTTP1.1协议(RFC2616)中定义了断点续传相关的HTTP头 Range和Co ...

  6. 再谈全局网HBase八大应用场景

    摘要: HBase可以说是一个数据库,也可以说是一个存储.拥有双重属性的HBase天生就具备广阔的应用场景.在2.0中,引入了OffHeap降低了延迟,可以满足在线的需求.引入MOB,可以存储10M左 ...

  7. 某某D的手伸的实在太长了,路由器也未能幸免,致被阉割的TP-Link

    前段时间整了个服务器架上l2tp.server, TP-Link路由连上去后,全网走l2tp通道,而且不能配置相关的路由表 然后研究啊 找啊 查啊,确定是路由没有这功能 找客服问了一下,他一听就懂了, ...

  8. October 12th 2017 Week 41st Thursday

    Be happy for this moment. This moment is your life. 为这一刻感到高兴,这一刻是你的人生. Yesterday Tencent became Asia ...

  9. python爬虫(三)

    webdriver Selenium是ThroughtWorks公司开发的一套Web自动化测试工具.它分为三个组件:Selenium IDE,Selenium RC (Remote Control), ...

  10. python第四十五课——继承性之多重继承

    演示多重继承的结构和使用 子类:Dog 直接父类:Animal 间接父类:Creature #生物类 class Creature: def __init__(self,age): print('我是 ...