博文
Visual Basic .NET处理Excel表格全接触(2008-04-18 19:41:00)
摘要:Visual Basic .Net处理Excel表格机理和处理Word文档一样,也是通过互操作,引入COM组件来实现的,所以前提条件是运行本文中介绍的程序的计算机必须安装Office 2000中的Excel软件。如果计算机安装的Office 2000,那么这个COM组件就是"Microsoft Excel 9.0 Object Library"。一旦引入此COM组件,Visual Basic .Net就可以向手工编辑Excel表格一样来处理它。下面就来介绍Visual Basic .Net处理Excel表格的各种典型操作,如创建表格、编辑表格等,以及从数据库中向Excel表格导入数据的实现方法。 一.本文程序设计、调试和运行的环境: (1).微软公司视窗2000服务器版。 (2).Visual Studio .Net2003企业构建版,.Net FrameWork SDK版本号4322。 (3).Office 2000套件。 二.Visual Basic .Net处理Excel表格的基本操作及其实现方法: 在Visual Basic .Net处理Excel表格之前,首先还是要引入COM组件,具体的实现步骤可参阅本文第三节中第八步。在引入的"Microsoft Excel 9.0 Object Library"COM组件后。下面介绍在Visual Basic .Net中处理Excel表格的典型操作的实现方法: 1. 创建Excel.exe进程,显示Excel界面,创建Excel表格: 成功引入COM组件后,通过下列语句就可以创建Excel.exe进程了,Visual Basic .Net就是通过对此进程的处理来操作Excel表格:
Private AppExcel As Excel.Application = New Excel.Application 当执行完此语句后,通过任务管理器查看进程就发现多出Excel.exe进程,当此时Excel程序的运行界面并没有显示,在此语句后加入以下代码,Excel的运行界面就显示出来了:
AppExcel.Visible = True Excel运行界面虽然显示,但其中并没有表格,下列代码是在Excel程序中创建一个新表格:
AppExcel.Application.W......
北京大学2008年研究生初试成绩化学院(2008-03-12 19:16:00)
摘要:
准考证号
政治
政治分
外语
外语分
科目1
科目1分
科目2
科目2分
总分
专业代码
专业名称
专业名次
考试方式
报名号
100018008100002
政治
69
英语
71
综合化学I
122
综合化学II
119
381
070301
无机化学
1
统
110199252
100018008100004
政治
76
英语
69
综合化学I
116
综合化学II
107
368
070301
无机化学
2
统
110195475
100018008100005
政治
63
英语
52
综合化学I
84
综合化学II
77
276
070302
分析化学
11
统
110198222
100018008100006
政治
75
英语
60
综合化学I
90
综合化学II
65
290
070302
分析化学
9
统
110197710
100018008100007
政治
59
英语
63
综合化学I
52
综合化学II
61
235
070302
分析化学
14
统
110197321
100018008100008
政治
52
英语
51
综合化学I
78
综合化学II
68
249
070302
分析化学
13
统
110192485
100018008100009
政治
71
英语
74
综合化学I
81
综合化学II
80
306
070302
分析化学
6
统
110193233
100018008100010
政治
55
英语
64
综合化学I
98
综合化学II
98
315
070302
分析化学
3
统
110197113
100018008100011
政治
68
英语
80
综合化学I
86
综合化学II
97
331
070302
分析化学
1
统
110189766
100018008100013
政治
62
英语
57
综合化学I
90
综合化学II
87
296
......
异步下载图片的方法(2008-03-02 11:11:00)
摘要:How to: Use Components That Support the Event-based Asynchronous Pattern
Many components provide you with the option of performing their work asynchronously. The SoundPlayer and PictureBox components, for example, enable you to load sounds and images "in the background" while your main thread continues running without interruption.
Using asynchronous methods on a class that supports the Event-based Asynchronous Pattern Overview can be as simple as attaching an event handler to the component's MethodNameCompleted event, just as you would for any other event. When you call the MethodNameAsync method, your application will continue running without interruption until the MethodNameCompleted event is raised. In your event handler, you can examine the AsyncCompletedEventArgs parameter to determine if the asynchronous operation successfully completed or if it was canceled.
For more information about using event handlers, see Event Handlers Overview (Windows Forms).
The follow......
Copy a Picture from a Database Directly (2008-02-20 21:19:00)
摘要:Sample
1.
Create a SQL Server or Access table with the following structure:CREATE TABLE BLOBTest
(
BLOBID INT IDENTITY NOT NULL,
BLOBData IMAGE NOT NULL
)
2.
Start Visual Studio .NET, and then create a new Visual Basic Windows Forms application.
3.
Drag a PictureBox control and two Button controls from the toolbox to the default Form1. Set the Text property of Button1 to File to Database, and then set the Text property of Button2 to Database to PictureBox.
4.
Add the following Imports statements at the top of the form's code module:Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Drawing.Imaging
5.
Add the following declaration for the database connection string below Public Class Form1, and then modify the connection string as necessary for your environment: Dim strCn As String = "Data Source=<server>;" & _
"Initial Catalog=<database>;Integrated Security=SSPI"
6......
Saving images in a database(2008-02-20 21:16:00)
摘要:Save the file as SaveImage.vb. Imports System
Imports System.IO
Imports System.Data
Public Class SaveImage
Shared Sub main()
'Declare a file stream object
Dim o As
System.IO.FileStream
'Declare a stream reader object
Dim r As
StreamReader
Dim jpgFile As String
Console.Write("Enter a Valid .JPG file path")
jpgFile = Console.ReadLine
If Dir(jpgFile) = "" Then
Console.Write("Invalid File Path")
Exit Sub
End If
'Open the file
o = New FileStream(jpgFile, FileMode.Open,
FileAccess.Read, FileShare.Read)
'Read the output in a stream reader
r = New StreamReader(o)
Try
'Declare a byte array to save the content of the file to be
saved
Dim FileByteArray(o.Length - 1) As Byte
o.Read(FileByteArray, 0, o.Length)
'Open the database connection. Please map the datasource name to match the 'Database path
Dim Con As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.3.51;Persist
Security Info=False;D......
在VB.NET中如何读取和存储ACESSS数据库中的图片(2008-02-20 21:15:00)
摘要:'首先将数据读入dataset中 Dim ImgByt() As Byte Dim ImgMS As IO.MemoryStream ImgByt = CType(dataset.Tables("表名").Rows(0).Item("图片字段名"), Byte()) ImgMS = New IO.MemoryStream(ImgByt) PictureBox1.image = Drawing.Image.FromStream(ImgMS) Try Dim strInsert As String Dim myconn......
将资料以二进制方式存入MsSql数据库(2008-02-20 21:13:00)
摘要:
将资料以二进制方式存入MsSql数据库
[日期:2007-11-23]
来源:asp.net魔法学院 作者:佚名
[字体:大 中 小]
这个范例示范了如何将档案存入资料库中的 Image 栏位及如何由 Image 栏位取出该档案。
假设资料表 Tb_File 有 ID,ExcelFile 两个栏位,ID 栏位型态为Integer,ExcelFile 栏位型态为 Image,先加入一笔记录,ID=1,ExcelFile=Null,范例中将Excel档案利用Update写入ID=1的记录中及由此记录读取 Image栏位内容并储存成档案。
’’’ <summary> ’’’ 读取档案内容写入Buffer中。 ’’’ </summary> Function FileToBuffer(ByVal FileName As String, ByRef Buffer() As Byte) As Boolean Dim oFileStream As System.IO.FileStream If Not System.IO.File.Exists(FileName) Then &nbs......
ASP.NET2.0中将文件上传到数据库(2008-02-20 21:11:00)
摘要:此问题经常被人问,本文列出将文字和图片上传到数据库的方法。包括Access数据库和SQL Server数据库。
Access数据库代码
上传文件到数据库
姓名:
照片:
SQL Server数据库代码
上传文件到数据库
姓名:
照片:
显示图片
创建SQL数据表语句
CREATE TABLE [UserPhoto] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[UserName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[ContentType] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Photo] [image] NOT NULL ,
CONSTRAINT [PK_UserPhoto] PRIMARY KEY CLUSTERED
(
......
最新气死老师的超强答案!!!笑死了(2007-04-18 19:56:00)
摘要:最新气死老师的超强答案!!! 作者: 郭华华 来源: 子陵论坛 http://bbs.ziling.com/......
碰上这样一个男人,你可以嫁了。(2007-04-08 16:06:00)
摘要:
碰上这样一个男人,你可以嫁了。评论(4)发表时间:2007年2月20日 10时7分
[%repeat_0 match="/data/option"%]
[%=@title%]
[%=@count%]票 [[%=@percent%]%][%_repeat_0%]
·有点害羞,但曾在分别街头,大声说我爱你。·同你去庙里求签,轻轻抓住你的手一同跪下。·言而有信。·从来不迟到——你迟到他不生气。·拥抱很久,很紧——每次你起身时几乎是需要慢慢推开他·睡的比你迟一点,醒来早一点。·朦胧醒来轻呼你的名字——没有呼错。·记得你的生日,鞋号,密码,最怕的事。·你很怕虫子,见到虫子大声尖叫他不会笑你。·笑起来很像个坏蛋——其实不是。·不舒服时,请假带你去看医生,回来路上买冰淇淋作奖励。·开车决不喝酒,让你系上安全带。·帮你做家务,每天,边做边聊天。·常常帮助别人,没有为什么。·答应你,永远不,然后永远不。·一边吹口哨一边修马桶。·说:希望你是他的女儿。·雨天散步背你过积水,说:你还可以再胖一些啊。·吵嘴时不会一走了之。·错了会认错。·你说笑话他笑。·逛街时你看中同一款式三种颜色的裙子,·他说:都试一遍好了。·试鞋时,他把你的卡通袜叠好塞进上衣口袋。·常常说,有我呢。·事情过了才告诉你,轻描淡写。·指甲整齐干净,喜欢你替他剪指甲。·你做的菜他每样都爱吃,要求明天再做。·小孩子都喜欢他,常常在楼下玩一裤子泥上来。·轻轻拧开你拧不开的汽水瓶。·与人争论像是在解释。·和你下棋,允许你悔棋。·他其实很早就对他的父母说起你。·喜欢运动,带你去健身俱乐部。·穿十年前的牛仔裤仍然合身。·他养了一条大狗,他的狗喜欢你。·吵架时你要他还给你送给他的维尼熊,他坚决不还。·吃你吃剩的东西。·你失眠时他陪你聊天。·你洗澡时他拿了本杂志进来坐在马桶上念。·比你高,你取不到的东西让他取。·重大的事情和你商量,比如明年的投资计划,周末野餐带不带烧烤架,晚上吃大白菜还是小白菜。·在商店的洗手间外面等你。·你感冒了,他还是会用你的杯子喝水。·手受伤了——因为看见小流氓在打女生上前揍他,捏住对方拔出的刀。·和大人在一起像大人,和孩子在一起像孩子,和狗在一起像狗。·喜欢你,从未犹豫,从不把你和别的女人比较。·常常央求你唱一首歌。·你买给他的东西都合他的心。·......
