Aspose.Cells.dll的用法
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的用法的更多相关文章
- C# WinForm 导出导入Excel/Doc 完整实例教程[使用Aspose.Cells.dll]
[csharp] view plain copy 1.添加引用: Aspose.Cells.dll(我们就叫工具包吧,可以从网上下载.关于它的操作我在“Aspose.Cells操作说明 中文版 下载 ...
- C# WinForm使用Aspose.Cells.dll 导出导入Excel/Doc 完整实例教程
1.添加引用: Aspose.Cells.dll(我们就叫工具包吧,可以从网上下载.关于它的操作我在“Aspose.Cells操作说明 中文版 下载 Aspose C# 导出Excel 实例”一文中的 ...
- Aspose.Cells.dll引用导入导出Excel
Aspose.Cells 导入导出EXCEL 文章出处:http://hi.baidu.com/leilongbing/item/c11467e1819e5417595dd8c1 修改样式 ...
- Aspose.Cells.dll操作execl
附件:Aspose.Cells.dll 1.创建execl(不需要服务器或者客户端安装office) public void DCExexl(DataTable dt) { Workbook wb ...
- C# Aspose.Cells.dll Excel操作总结
简介 Aspose.Cells是一款功能强大的 Excel 文档处理和转换控件,不依赖 Microsoft Excel 环境,支持所有 Excel 格式类型的操作. 下载 Aspose.Cells.d ...
- C# 读写Excel的一些方法,Aspose.Cells.dll
需求:现有2个Excel,一个7000,一个20W,7000在20W是完全存在的.现要分离20W的,拆分成19W3和7000. 条件:两个Excel都有“登录名”,然后用“登录名”去关联2个Excel ...
- C# 利用Aspose.Cells .dll将本地excel文档转化成pdf(完美破解版 无水印 无中文乱码)
Aspose.Cells .dll下载 http://pan.baidu.com/s/1slRENLF并引用 C#代码 using System; using System.Collections. ...
- ExportGrid Aspose.Cells.dll
using Aspose.Cells; using Aspose.Words; using System; using System.Collections; using System.Collect ...
- Aspose Cells dll 实现数据简单下载
Workbook workbook = new Workbook(); //工作簿 Worksheet sheet = workbook.Worksheets[ ...
随机推荐
- Expo大作战(十六)--expo结合firebase 一个nosql数据库(本章令我惊讶但又失望!)
简要:本系列文章讲会对expo进行全面的介绍,本人从2017年6月份接触expo以来,对expo的研究断断续续,一路走来将近10个月,废话不多说,接下来你看到内容,讲全部来与官网 我猜去全部机翻+个人 ...
- css设计并排布局
css code form#reset_password ul { list-style: none; margin: 0 0 20px 200px; padding:; } form#reset_p ...
- HTML 5 Web Workers
什么是Web Worker? web worker 是运行在后台的 JavaScript,不会影响页面的性能. Web Worker有什么用? JavaScript语言采用的是单线程模型,也就是说,所 ...
- 文科妹学 GitHub 简易教程
#什么是 Github ?必须要放这张图了!!!<img src="https://pic4.zhimg.com/7c9d3403bf922b1663f56975869c829b_ ...
- Solving the SQL Server Multiple Cascade Path Issue with a Trigger (转载)
Problem I am trying to use the ON DELETE CASCADE option when creating a foreign key on my database, ...
- 什么是套接字(Socket)
应用层通过传输层进行数据通信时,TCP和UDP会遇到同时为多个应用程序进程提供并发服务的问题.多个TCP连接或多个应用程序进程可能需要 通过同一个TCP协议端口传输数据.为了区别不同的应用程序进程和连 ...
- android下载 sdk 的两个代理 ,解决下载sdk慢的问题
mirrors.opencas.cn mirrors.neusoft.edu.cn 设置教程:http://blog.csdn.net/mociml/article/details/1633125 ...
- MySQL基础之 如何删除主键
我们在一个表中设置了主键之后,那么如何删除主键呢? 删除主键的语法是: ALTER TABLE TABLE_NAME DROP PRIMARY KEY; 在这里我们要考虑两种情况: 1.可以直接使用d ...
- 根据字体多少使UILabel自动调节尺寸
原文:http://blog.csdn.net/enuola/article/details/8559588 在大多属性情况下,给UILabel进行动态数据绑定的时候,往往需要根据字符串的多少,动态调 ...
- November 15th, 2017 Week 46th Wednesday
Of all the tribulations in this world, boredom is the one most hard to bear. 所有的苦难中,无聊是最难以忍受的. When ...