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[ ...
随机推荐
- Android Relative Layout 安卓相对布局详解
思维导图可在幕布找到 1. 基础 如果在相对布局里,控件没有指明相对位置,则默认都是在相对布局的左上角: <TextView android:layout_width="wrap_co ...
- 如何用 Python 实现 Web 抓取?
[编者按]本文作者为 Blog Bowl 联合创始人 Shaumik Daityari,主要介绍 Web 抓取技术的基本实现原理和方法.文章系国内 ITOM 管理平台 OneAPM 编译呈现,以下为正 ...
- 解决Hsqldb指针只能单向移动,不能回滚问题(.first())
Class.forName("org.hsqldb.jdbcDriver").newInstance(); Connection con = java.sql.DriverMana ...
- MySQL之UNDO及MVCC、崩溃恢复
UNDO特性:避免脏读.事务回滚.非阻塞读.MVCC.崩溃恢复 事务工作流程(图2) MVCC原理机制 崩溃恢复:redo前滚.undo回滚 长事务.大事务:危害.判断.处理 UNDO优化:实现u ...
- surging API
基于.NET CORE微服务框架 -谈谈surging API网关 基于.NET CORE微服务框架 -浅析如何使用surging surging 系列 NET Core 2.0 在WIN7系统 的H ...
- python-ldap修改AD域用户密码(CA+SSL)
代码连接:https://github.com/raykuan/ldap-notes 使用python的ldap模块连接AD服务器,有两种方式: 非加密:con = ldap.initialize(' ...
- November 16th, 2017 Week 46th Thursday
Don't you wonder sometimes, what might have happened if you tried. 有时候,你会不会想,如果当初试一试会怎么样? If I had t ...
- python 使用csv 文件写入 出现多余空行数据解决方案
因为csv.writerow() 方法会造成读取时每条数据后多一条空数据 解决方案如下: 分为两种情况 python2 和 python3 先说python2版本 with open('xxx.csv ...
- 配置好jdk后,cmd编写java -version还是报找不到jdk
找了好长时间没查出问题在哪,配置的都没有问题,最后搜了搜网上发现,jdk的这两行得在最上面才行.
- canvas实例_时钟
效果图:是一个会动的时钟 一.时钟的组成 1.表盘(蓝色) 2.刻度(黑色) 3.时针(黑色) 4.分针(黑色) 5.秒针(红色)需美化 二.主要应用的技术 Canvas画线 Canv ...