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. sql语句查找某一列的值得最大值。

    记录一下:sql语句查找某一列的值得最大值. 1.例如我要查找 表A中a列的最大值: 查找语句可以这么写: "select Max(a) a from A" 2.查找表A中a列中包 ...

  2. Android逆向 Android平台虚拟机

    一 Dalvik:是Google开发运行在Android平台的Java虚拟机, Android程序编译后会生成dex文件.Dalvik虚拟机下运行Java时,要将字节码通过即时编译器(just in ...

  3. 【疑难杂症02】ResultSet.next() 效率低下问题解决

    今天帮同事解决了一个问题,记录一下,帮助有需要的人. 一.问题解决经过 事情的经过是这样的,下午我在敲代码的时候,一个同事悄悄走到我身边,问我有没有用没用过Oracle,这下我蒙了,难道我在他们眼中这 ...

  4. 【python】python中的json、字典dict

    定义 python中,json和dict非常类似,都是key-value的形式,而且json.dict也可以非常方便的通过dumps.loads互转.既然都是key-value格式,为啥还需要进行格式 ...

  5. centos6.5安装mysql

    1.yum -install  mysql mysql-server -y 2.修改mysql的root的密码 登录:mysql -uroot        修改密码:            use ...

  6. 解决:Determining IP Information for eth0...问题

    环境:Centos 6.2     VMWare Workstation 7.1.2  故障现象: 在虚拟机中启动Centos,在启动页面中停留在Determining IP Information ...

  7. 设置联想键盘恢复F1~F12默认按键的操作办法

    背景 默认都是笔记本键盘才有Fn组合功能键,台式机很少有.今天领到的是联想键盘,给我的台式机使用后F12很麻烦,必须Fn+F12才可以. 需求 恢复默认的F1~F12功能 方案 只需要下载驱动安装: ...

  8. List特有迭代器--ListIterator的特殊功能

    /** *    >列表迭代器: *            ListIterator listIterator():List集合特有的迭代器 *            该迭代器继承了Iterat ...

  9. Docker容器学习与分享02

    1.docker容器的创建 首先运行一个centos容器,感受一下Docker容器的便捷 首先先看一下镜像仓库 发现仓库里没有镜像,也就是没有创建容器的模板,这时考虑从REPOSITORY中拉取镜像( ...

  10. js 毫秒转换为标准时间

    function dateForm(time){ var unixTimestamp = new Date( 1477386005*1000 ); commonTime = unixTimestamp ...