随笔分类 -  C#

.Net C#
导出excel后关闭excel进程
摘要:[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)] static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId); worksheet.SaveAs(filePath, Microsoft.Off... 阅读全文

posted @ 2017-01-19 16:02 数据结构X 阅读(823) 评论(0) 推荐(0)

导入Excel部分数据导入不了的原因及处理
摘要:用C#将一个EXCEL导入到DATASET中(使用Microsoft.Jet.OleDb.4.0),但是读出来的时候发现有些数据没有导入,不同的EXCEL情况也不一样,有的EXCEL是纯数字没有导入进去,有的是纯字符没有导入进去,有的整个列都没数据。 原因及处理办法: Excel驱动程序读取指定源中一定数量的行(默认情况下为 8 行)以推测每列的数据类型。如果推测出列可能包含混合数据类型(尤其是混合了文本数据的数值数据时),驱动程序将决定采用占多数的数据类型,并对包含其他类型数据的单元返回空值。(如果各种数据类型的数量相当,则采用数值类型。) 当前8行为空时,整个列都将变为空值。 采... 阅读全文

posted @ 2012-11-27 12:35 数据结构X 阅读(2374) 评论(0) 推荐(0)

Devexpress GridView添加行号
摘要://在GridView的CustomDrawRowIndicator事件中添加如下代码: private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e) { if (e.Info.IsRowIndicator && e.RowHandle >= 0) { e.Info.DisplayText = e.Row... 阅读全文

posted @ 2012-07-12 12:32 数据结构X 阅读(454) 评论(0) 推荐(0)

Devexpress GridControl 常用设置
摘要:2012-05-14 16:35:12标签:GridControl Grid devexpress 使用方法 技巧一、如何解决单击记录整行选中的问题View->OptionsBehavior->EditorShowMode 设置为:Click二、如何新增一条记录(1)、gridView.AddNewRow()(2)、实现gridView_InitNewRow事件三、如何解决GridControl记录能获取而没有显示出来的问题gridView.populateColumns();四、如何让行只能选择而不能编辑(或编辑某一单元格)(1)、View->OptionsBehavior 阅读全文

posted @ 2012-06-04 14:12 数据结构X 阅读(861) 评论(0) 推荐(1)

BindingSource.AddingNew事件给新增数据设置初始值
摘要:private void tableBindingSource_AddingNew(object sender, AddingNewEventArgs e){ BindingSource bs = (BindingSource)sender; DataView view = (DataView)bs.List; DataRowView row = view.AddNew(); row["id"] = Guid.NewGuid(); if (bs.Count == 1) ... 阅读全文

posted @ 2012-01-06 15:10 数据结构X 阅读(632) 评论(0) 推荐(0)

判断Windows服务是否已经启动
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ServiceProcess;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { ServiceIsExisted("MSSQLSERVER"); } private static bool ServiceIs... 阅读全文

posted @ 2011-12-14 11:10 数据结构X 阅读(310) 评论(0) 推荐(0)

常用的对称加密算法代码
摘要:using System;using System.Collections.Generic;using System.Text;using System.Security.Cryptography;using System.IO; namespace Regent.TCommons{ /// <summary> /// '******************************************************** /// 模块名称: 安全类 /// 模块功能: 常用的对称加密算法代码。 /// </summary> publi... 阅读全文

posted @ 2011-12-14 10:58 数据结构X 阅读(457) 评论(0) 推荐(0)

导航