ช่วยดู Error ออกรายงานด้วย Excel ให้ทีครับลองแก้มานานแล้วยังไม่ได้
ใช้ Office2003
Error Code:
Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))
ในส่วนของ Add Reference
1. Microsoft Excel 11.0 Object Library
2. Microsoft Office 10.0 Object Library
Code (VB.NET)
Public Oxl As Excel.Application
Public Owb As Excel.Workbook
Public OSheet As Excel.Worksheet
Imports Microsoft.Office.Core
Imports System.IO
Call Kill_Process()
Dim File_Name As String = "บาร์โค๊ตรหัส " & TxtWord.Text & TxtStart.Text & "-" & TxtWord.Text & TxtFinish.Text
Oxl = CreateObject("Excel.Application")
Dim A = Application.StartupPath & "\barcode\collection\"
FileCopy(Application.StartupPath & "\barcode\original\BarCode.xls", A & File_Name & ".xls")
Owb = Oxl.Workbooks.Open(A & File_Name & ".xls")//Error Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))
Oxl.Visible = True
'-------------------------
Dim BarCode As String : Dim Word As String = Nothing
Dim i, Start, Finish, Count, Colum, Row As Integer
Start = Val(TxtStart.Text) - 1 : Finish = Val(TxtFinish.Text) - 1
Count = Start : Colum = 1 : Row = 0
OSheet = Owb.ActiveSheet
For i = Start To Finish
Count += 1
BarCode = TxtWord.Text & String.Format("{1:000000}", "", Count)
' MsgBox(BarCode)
Row += 1
If Row = 12 Then
Colum += 1 : Row = 1
End If
With OSheet
.Cells(Colum, Row).Value = BarCode
.Cells(Colum, Row).Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlContinuous
.Cells(Colum, Row).Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = Excel.XlLineStyle.xlContinuous
.Cells(Colum, Row).Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous
.Cells(Colum, Row).Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlContinuous
End With
Next
Count = 0 : Colum = 0 : Row = 0
Tag : .NET, Ms Access, Ms SQL Server 2005, VB.NET
Date :
2010-09-16 14:56:01
By :
babyprogrammer
View :
1706
Reply :
2
ขอบคุณพี่วินมากครับ แต่ผมสงสัยอีกอย่างนึง เราจะมีวิธีเช็คได้หรือเปล่าครับว่าแต่ละเครื่องใช้ Th หรือว่า En
System.Threading.Thread.CurrentThread.CurrentCulture = new ystem.Globalization.CultureInfo("en-US")
System.Threading.Thread.CurrentThread.CurrentCulture = new ystem.Globalization.CultureInfo("th-TH")
Date :
2010-09-16 17:10:51
By :
babyprogrammer
Load balance : Server 04