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[ ...
随机推荐
- Hive 锁 lock
Hive + zookeeper 可以支持锁功能 锁有两种:共享锁.独占锁,Hive开启并发功能的时候自动开启锁功能 1)查询操作使用共享锁,共享锁是可以多重.并发使用的 2)修改表操作使用独占锁,它 ...
- [Android] 针对生成的图片文件在系统Gallery不显示的处理
之前遇到过一个问题,就是发现我在程序中生成一个新的 Bitmap 之后,当我打开系统的 Gallery 查看时,并没有看到新生成的图像.然而打开文件浏览器,找到保存 Bitmap 所在的文件夹下,还能 ...
- Git仓库初始化与推送到远端仓库
以下命令为Git仓库初始化,添加远端代码托管仓库,以及推送到远端仓库的命令. 以 "github.com"为远端仓库做示例 # Git 库初始化 git init # 将文件添加到 ...
- SQL Server全文搜索
SQL Server全文搜索 看这篇文章之前请先看一下下面我摘抄的全文搜索的MSDN资料,基本上MSDN上关于全文搜索的资料的我都copy下来了 并且非常认真地阅读和试验了一次,并且补充了一些SQL语 ...
- 什么是 Azure 中的虚拟机规模集?
虚拟机规模集是一种 Azure 计算资源,可用于部署和管理一组相同的 VM. 由于所有 VM 的配置都相同,因此无需对 VM 进行任何预先配置. 这样就可以更方便地构建面向大型计算.大数据.容器化工作 ...
- VUE中v-on:click事件中获取当前dom元素
在开发中总是忘记, 特意在此记录 关键字: $event <div class="bed" v-on:click="updateBed(index,$e ...
- Sql Server与.Net(C#)中星期值对比
最近发现Sql Server与.Net(C#)中星期值居然不匹配,倒不知道依哪一个了. 1.Sql Server declare @date datetime; set @date = '2017-0 ...
- MySQL安全策略
0.导读 MySQL被运用于越来越多的业务中,在关键业务中对数据安全性的要求也更高,如何保证MySQL的数据安全? MySQL被运用于越来越多的业务中,在关键业务中对数据安全性的要求也更高,如何保证M ...
- [日常] HEOI 2019 退役记
HEOI 2019 退役记 先开坑 坐等AFO 啥时候想起来就更一点(咕咕咕) Day 0 早上打了个LCT, 打完一遍过编译一遍AC...(看来不考这玩意了) 然后进行了一些精神文明建设活动奶了一口 ...
- include_path='.;C:\php5\pear'解决方法
问题原因:路径中出现中文, 解决方法:你懂的,,