| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 700 人关注过本帖
标题:如何在vb.net 中把数据存入到excel中?
只看楼主 加入收藏
04soft
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-6-17
收藏
 问题点数:0 回复次数:2 
如何在vb.net 中把数据存入到excel中?
还请高手多多指教啊!
搜索更多相关主题的帖子: excel 数据 指教 
2006-06-17 21:48
hangover
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-6-4
收藏
得分:0 
Module Module1

Sub Main()

Dim excel As Excel.ApplicationClass = New Excel.ApplicationClass
Dim wb As Excel.WorkbookClass
Dim ws As Excel.Worksheet

wb = excel.Workbooks.Open("C:\Documents and Settings\work\Desktop\ConsoleApplication1\Yang")
wb.Activate()
ws = wb.Worksheets.Add
excel.Visible = True

Dim ran As RandomUniform = New RandomUniform
ran.randomSetSeed(10)

Dim i As Integer
For i = 1 To 10
ws.Cells(i, 3).Value = ran.randomUniform()
Next

ws.Cells(1, 2).Value = excel.WorksheetFunction.Sum(excel.Range("C1:C10"))

End Sub

End Module

2006-06-21 07:07
hangover
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-6-4
收藏
得分:0 
'' This is an implementation of the algorithm used in Numerical
' Recipe's ran0 generator. It is the same as MINSTD with an XOR mask
' of 123459876 on the seed.

' The period of this generator is 2^31.

' Note, if you choose a seed of 123459876 it would give a degenerate
' series 0,0,0,0, ... I've made that into an error.

Public Class RandomUniform
Private Const m As Long = 2147483647
Private Const a As Long = 16807
Private Const q As Long = 127773
Private Const r As Long = 2836
Private Const mask As Long = 123459876
Private state As Long

Private Function randomGet() As Long
Dim h As Long = state / q
Dim t As Long = a * (state - h * q) - h * r
If t < 0 Then
state = t + m
Else
state = t
End If
Return state
End Function

Public Function randomUniform() As Double
Return randomGet() / 2147483647.0
End Function

Public Sub randomSetSeed(ByVal s As Long)
If s = mask Then
Console.WriteLine("Error")
End If
state = s Xor mask
End Sub

Public Function randomUniformPositive() As Double
Dim x As Double
Do
x = randomUniform()
Loop While x = 0
Return x
End Function

End Class
2006-06-21 07:08
快速回复:如何在vb.net 中把数据存入到excel中?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013690 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved