|
|
 |
| General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums. If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category.
** PLEASE BE SPECIFIC WITH YOUR QUESTION **
When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the General .NET section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

February 18th, 2008, 06:33 AM
|
|
Registered User
|
|
Join Date: Feb 2008
Location: Delhi, , India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Exception from HRESULT: 0x800A03EC
Hi friend plz help me
i m putting data from a dataset to an excel file in windows application.
after setting value of 2 cells
i m getting this error : Exception from HRESULT: 0x800A03EC
the code is
Dim MyExcel As New Microsoft.Office.Interop.Excel.Application
Try
MyExcel.Workbooks.Open(Application.StartupPath() & "\Preview\WorkSheet1.xls")
Catch ex As Exception
MsgBox("Open : " & ex.Message)
MyExcel = Nothing
End Try
MyExcel.ActiveWorkbook.ActiveSheet.Cells(5, 1) = ("Party Ledger for Party " & ds.Tables(0).Rows(0).Item("PartyName"))
MyExcel.ActiveWorkbook.ActiveSheet.Cells(6, 1) = ("From " & CDate(ds.Tables(0).Rows(0).Item("Date")).Date & " To " & CDate(ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1).Item("Date")).Date)
Dim rows As Integer = 8
Dim TotalDr As Decimal = 0
Dim TotalCr As Decimal = 0
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 0) = i + 1
' getting error here
MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 1) = ds.Tables(0).Rows(i).Item("Description")
MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 2) = ds.Tables(0).Rows(i).Item("Date")
If ds.Tables(0).Rows(i).Item("Type") = "Sales" Or ds.Tables(0).Rows(i).Item("Type") = "Issue" Then
MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 3) = CDbl(ds.Tables(0).Rows(i).Item("Ammount"))
TotalDr = totaldr + CDbl(ds.Tables(0).Rows(i).Item("Ammount"))
Else
MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 3) = ""
End If
If ds.Tables(0).Rows(i).Item("Type") = "Purchase" Or ds.Tables(0).Rows(i).Item("Type") = "Receive" Then
MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 4) = CDbl(ds.Tables(0).Rows(i).Item("Ammount"))
TotalCr = TotalCr + CDbl(ds.Tables(0).Rows(i).Item("Ammount"))
Else
MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 4) = ""
End If
If ds.Tables(0).Rows(i).Item("ClosingBalance") < 0 Then
MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 5) = ds.Tables(0).Rows(i).Item("ClosingBalance") & " Cr"
ElseIf ds.Tables(0).Rows(i).Item("ClosingBalance") > 0 Then
MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 5) = ds.Tables(0).Rows(i).Item("ClosingBalance") & " Dr"
End If
rows = rows + i
Next
Dim fpath As String
Try
fpath = Application.StartupPath() & "WorkSheet1" & Date.Today.Day * Date.Today.Second & "" & ds.Tables(0).Rows(0).Item("PartyName") & ".xls"
MyExcel.ActiveWorkbook.SaveAs(fpath)
MsgBox("File Saved successfully")
Catch ex As Exception
MsgBox("Problem occur during saving report, Please Try Again.")
MyExcel = Nothing
Finally
MyExcel.ActiveWorkbook.Close(False, Application.StartupPath() & "\Preview\SuccessRateByPayer.xls")
MyExcel.DisplayAlerts = False
MyExcel = Nothing
End Try
End Sub
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |