剛剛弄出來的東西.
DsExport.vb :
Public Class DsExport
Public Shared Function Export(ByVal ds As DataSet, _
ByVal dtName As String, _
ByVal colList() As String, _
ByVal colValue() As Integer) As String
Dim header As String = ""
Dim body As String = ""
Dim record As String = ""
For Each col As String In colList
header = header & Chr(34) & col & Chr(34) & ","
Next
header = header.Substring(0, header.Length - 1)
For Each row As DataRow In ds.Tables(dtName).Rows
Dim arr() As Object = row.ItemArray()
For Each i As Integer In colValue
If arr(i).ToString().IndexOf(",") > 0 Then
record = record & Chr(34) & arr(i).ToString() & Chr(34) & ","
Else
record = record & arr(i).ToString() & ","
End If
Next
body = body & record.Substring(0, record.Length - 1) & vbCrLf
record = ""
Next
Return header & vbCrLf & body
End Function
End Class
呼叫方式:
Private Sub BtnExport_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles BtnExport.Click
Dim colList() As String = {"CSV表頭1", "CSV表頭2", "CSV表頭3"}
"顯示順序: SQL query 刮出來的欄位0, 4, 2
Dim colValue() As Integer = {0, 4, 2}
Dim strData As String = _
DsExport.Export(DataSet 變數名稱, _
"DataSet 變數中的 DataTabel 名稱", _
colList, colValue)
Dim binData() As Byte = System.Text.Encoding.Default.GetBytes(strData)
Response.Clear()
Response.AddHeader("Content-Type", "application/vnd.ms-access")
Response.AddHeader("Content-Disposition", "inline;filename=檔案名稱.csv")
Response.BinaryWrite(binData)
Response.End()
End Sub
2 月 8 2007
Vista 裝好了,驅動程式呢?
Vista 上市了, Microsoft 也花了不少錢在許多電視頻道上狂打廣告。
我的桌上型電腦之前被我作成 Windows XP & Windows 2003 雙系統。
昨晚我把桌上型電腦的 Windows 2003 洗掉,改裝 Windows Vista Ultimate (在台灣叫 Windows Vista 旗艦版 )。
不過我很快就發現到這幾點問題:
很慶幸地,我的 GeForce 6200 可以讓我順暢的使用 Aero (包括 Flip3D )。
幸好我是把 Windows 2003 洗掉,而我還能切換回 Windows XP ,不然我就得再重灌一遍了。
坦白說,我一向很欣賞 nVidia 的驅動程式包裝方式。
nVidia 的驅動程式一向都能自動偵測硬體,自動安裝需要的驅動程式,而新版本的作業系統支援速度也相當快。
許多顧客與廠商愈來愈要求售後服務水準,而 nVidia 的驅動程式包裝方式應該可以說是台灣許多硬體廠商需要效法的目標。
By Joe Horn • Windows 2 • Tags: driver, Vista, Windows