Click here to Skip to main content
15,888,984 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Rs232 Initialization? Pin
Ray Cassick24-Mar-06 11:45
Ray Cassick24-Mar-06 11:45 
QuestionThis remoting proxy has no channel sink Pin
Tom Mat23-Mar-06 2:34
Tom Mat23-Mar-06 2:34 
Questioncombo box contents not updating in Windows Forms Pin
analytiks22-Mar-06 22:01
analytiks22-Mar-06 22:01 
AnswerRe: combo box contents not updating in Windows Forms Pin
analytiks23-Mar-06 17:27
analytiks23-Mar-06 17:27 
Questionxml schema question Pin
Brayan__22-Mar-06 5:15
Brayan__22-Mar-06 5:15 
Generalprogram.exe has encountered a problem and needs to close. Pin
Jan R Hansen21-Mar-06 23:08
Jan R Hansen21-Mar-06 23:08 
GeneralRe: program.exe has encountered a problem and needs to close. Pin
Vasudevan Deepak Kumar22-Mar-06 18:31
Vasudevan Deepak Kumar22-Mar-06 18:31 
QuestionASP.Net How to set up page property for an in memory Excel worksheet Pin
JWU VB.Net21-Mar-06 6:33
JWU VB.Net21-Mar-06 6:33 
Dear all,

I am doing a project which is loading the data from a DataSet into an in memory object Excel worksheet, then setting up the PrintTitleRows for the Excel worksheet, finally redirecting the in memory Excel worksheet to the client side.

When I run it, the error message is "System.Runtime.InteropServices.COMException (0x800A03EC): Unable to set the PrintTitleRows property of the PageSetup class at System.RuntimeType."

The following is my code, anyone can help me with it is highly appreciated.

Dim excelCol As New excelColumn
Public Structure excelColumn
Public data() As String
End Structure
Dim dt As New DataSet 'DataSet is filled in another fuction

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim iRow As Integer
Dim iCol As Integer
Dim myTable As DataTable
Dim filename As String

excelCol.data = New String(4) {}
excelCol.data(1) = "A"
excelCol.data(2) = "B"
excelCol.data(3) = "C"

Dim qxl As New Excel.Application
Dim qxlwb As Excel.Workbook
Dim qxlws, qxlwstemp As Excel.Worksheet

qxlwb = qxl.Workbooks.Add()
qxl.Visible = True
qxlws = DirectCast(qxlwb.Worksheets.Add, Excel.Worksheet)
qxlws.Name = "All Columns"

Try

For iRow = 0 To dt.Tables(0).Rows.Count - 1
For iCol = 0 To dt.Tables(0).Columns.Count - 1
If (iRow = 0) Then
qxlws.Range((excelCol.data(iCol + 1)) & CStr(iRow + 1)).Value = dt.Tables(0).Columns(iCol).ColumnName
End If
If (Not ((dt.Tables(0).Rows(iRow).Item(iCol)) Is DBNull.Value)) Then
qxlws.Range((excelCol.data(iCol + 1)) & CStr(iRow + 2)).Value = DirectCast(CStr(dt.Tables(0).Rows(iRow).Item(iCol)), String)
End If
If ((dt.Tables(0).Rows(iRow).Item(iCol)) Is DBNull.Value) Then
qxlws.Range((excelCol.data(iCol + 1)) & CStr(iRow + 2)).Value = ""
End If
Next iCol
Next iRow
qxlws.PageSetup.PrintTitleRows = "$1:$2"
'Me.Label1.Text = qxlws.Range((excelCol.data(2)) & CStr(9)).Value
Response.ContentType = "application/vnd.ms-excel"

Response.Write(qxlwb)

qxlws = Nothing
qxlwb = Nothing
qxl = Nothing

Catch ex As Exception
Me.Label1.Text = ex.ToString
Finally
If Not (qxlws Is Nothing) Then
ReleaseComObject(qxlws)
qxlws = Nothing
End If

If Not (qxlwb Is Nothing) Then
ReleaseComObject(qxlwb)
qxlwb = Nothing
End If

If Not (qxl Is Nothing) Then
ReleaseComObject(qxl)
qxl = Nothing
End If

System.GC.Collect()
End Try
End Sub



Jwu
QuestionPOKECTPC GSM DATA CONNETION Pin
GPShady21-Mar-06 0:15
GPShady21-Mar-06 0:15 
QuestionDeploying my .NET app (started as MFC program)... HELP!!! Pin
anderslundsgard20-Mar-06 22:15
anderslundsgard20-Mar-06 22:15 
QuestionOn hold... Pin
Jam.X20-Mar-06 4:15
Jam.X20-Mar-06 4:15 
AnswerRe: On hold... Pin
Dave Kreskowiak20-Mar-06 10:11
mveDave Kreskowiak20-Mar-06 10:11 
GeneralRe: On hold... Pin
Jam.X20-Mar-06 13:36
Jam.X20-Mar-06 13:36 
QuestionInserting Page Break Pin
User 246299120-Mar-06 3:04
professionalUser 246299120-Mar-06 3:04 
AnswerRe: Inserting Page Break Pin
Robert Rohde20-Mar-06 7:20
Robert Rohde20-Mar-06 7:20 
GeneralRe: Inserting Page Break Pin
User 246299120-Mar-06 17:12
professionalUser 246299120-Mar-06 17:12 
QuestionAutoCad Tool Palette with .Net Pin
prakashdotc20-Mar-06 2:26
prakashdotc20-Mar-06 2:26 
QuestionIList vs array performance observation (.NET 2.0) Pin
wout de zeeuw19-Mar-06 22:52
wout de zeeuw19-Mar-06 22:52 
AnswerRe: IList vs array performance observation (.NET 2.0) Pin
ricardojb20-Mar-06 9:29
ricardojb20-Mar-06 9:29 
GeneralRe: IList vs array performance observation (.NET 2.0) Pin
wout de zeeuw20-Mar-06 10:11
wout de zeeuw20-Mar-06 10:11 
GeneralRe: IList vs array performance observation (.NET 2.0) Pin
Ed.Poore24-Mar-06 8:01
Ed.Poore24-Mar-06 8:01 
GeneralRe: IList vs array performance observation (.NET 2.0) Pin
wout de zeeuw24-Mar-06 9:15
wout de zeeuw24-Mar-06 9:15 
GeneralRe: IList vs array performance observation (.NET 2.0) Pin
Ed.Poore24-Mar-06 10:57
Ed.Poore24-Mar-06 10:57 
QuestionIs this possible? Pin
Xaake19-Mar-06 10:48
Xaake19-Mar-06 10:48 
AnswerRe: Is this possible? Pin
Dave Kreskowiak19-Mar-06 12:36
mveDave Kreskowiak19-Mar-06 12:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.