|
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
|
|
|
|
|
HI,
I have a big problem. I don't know how make a GSM DATA CONNECTION with my PocketPC. I try to use TAPI. I succeed to make voicecall with MakeCall method, but i need to make datacall and connection GSM. I see a eVC program that me permit to make datacall, but i don't know how implement it in .NET2003. Who help me?
Thank's
Giuseppe Peschiera
g.peschiera@tiscali.it
Eng. Giuseppe Peschiera
|
|
|
|
|
I've started to use /clr in my old MFC app using VS 2005
How do I distribute my application in an easy way? It only works on computers having visual studio 2005.
I have run Dependency Walker an error is shown:
Error: The Side-by-Side configuration information in "MyApp.exe"contains errors. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem (14001)
I got the following error when I try to launch my app:
This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem
All I want is to make my application run on another computer before lunchtime...
I have the .NET Framework 2.0 (dotnetfx.exe) installed on my other cpu.
_____________________________
...and justice for all
APe
|
|
|
|
|
Hi guys...
As you can probably tell from my question i am new to programming c# & the .net framework.
My question is to ask if it is possible to create an application that will play music when a caller is put on hold?(using a smart device).
Any help is greatly appriciated.
Regards.
|
|
|
|
|
That would depend heavily on your phones ability to even do this, regardless of the code used. You might want to find out before wasting a bunch of time trying to code something that will never work.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
unable to find any info so far...my phone is an spv m2000 (MS Mobile 2003).
|
|
|
|
|
Dear All
Kindly help me to insert a page break while printing using .net print document. I am printing using System.Drawing.Printing.PrintPageEventArgs.Graphics object.
Aman Tur
modified 9-Jul-22 21:01pm.
|
|
|
|
|
You do not explicitely insert a page break. Just set the HasMorePages property of the PrintPageEventArgs to true and another PrintPage event will fire after the current one is finished.
|
|
|
|
|
Thanks Roberts i found the solution few minutes later in some other code project article.
Regards
Aman Tur
modified 9-Jul-22 21:01pm.
|
|
|
|
|
Hi,
I'm trying to create a Tool Palette with some basic tools for AutoCad 2006 with .Net 2003, form which the user can drag and drop the tool directly from the Tool Pallete, can any one help me in this regard, thank U in advance.
Prakash.C
|
|
|
|
|
I was wanted to share some performance observations after fiddling around with arrays and IList<type> . Since e.g. a double[] a array automatically implements IList<double> in .NET 2.0 I can conveniently accept IList<double> as argument for any method without also needing an overload for double[] . However, after some quick testing it seems a performance penalty is involved using the IList interface! I used this small program to compare the options:
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace TestListVsArray {<br />
class Program {<br />
static void Main(string[] args) {<br />
double[] a = new double[10000];<br />
<br />
for (int i = 0; i < 3; i++) {<br />
TestA(a);<br />
TestB(a);<br />
TestC(a);<br />
TestD(a);<br />
Console.WriteLine();<br />
}<br />
}<br />
<br />
private static void TestA(IList<double> a) {<br />
DateTime start = DateTime.Now;<br />
double x = 0d;<br />
for (int j = 0; j < 1000; j++) {<br />
for (int i = 0; i < a.Count; i++) {<br />
x += a[i];<br />
}<br />
}<br />
Console.WriteLine("{0}, {1}", DateTime.Now - start, x);<br />
}<br />
<br />
private static void TestB(IList<double> a) {<br />
DateTime start = DateTime.Now;<br />
double x = 0d;<br />
int n = a.Count;<br />
for (int j = 0; j < 1000; j++) {<br />
for (int i = 0; i < n; i++) {<br />
x += a[i];<br />
}<br />
}<br />
Console.WriteLine("{0}, {1}", DateTime.Now - start, x);<br />
}<br />
<br />
private static void TestC(double[] a) {<br />
DateTime start = DateTime.Now;<br />
double x = 0d;<br />
for (int j = 0; j < 1000; j++) {<br />
for (int i = 0; i < a.Length; i++) {<br />
x += a[i];<br />
}<br />
}<br />
Console.WriteLine("{0}, {1}", DateTime.Now - start, x);<br />
}<br />
<br />
private static void TestD(double[] a) {<br />
DateTime start = DateTime.Now;<br />
double x = 0d;<br />
int n = a.Length;<br />
for (int j = 0; j < 1000; j++) {<br />
for (int i = 0; i < n; i++) {<br />
x += a[i];<br />
}<br />
}<br />
Console.WriteLine("{0}, {1}", DateTime.Now - start, x);<br />
}<br />
}<br />
}<br />
Output on my machine was (tests are repeated to rule out exceptional starting behaviour):
<br />
00:00:01.1015840, 0<br />
00:00:00.6008640, 0<br />
00:00:00.0801152, 0<br />
00:00:00.0801152, 0<br />
<br />
00:00:01.0915696, 0<br />
00:00:00.6008640, 0<br />
00:00:00.0801152, 0<br />
00:00:00.0801152, 0<br />
<br />
00:00:01.0815552, 0<br />
00:00:00.6108784, 0<br />
00:00:00.0801152, 0<br />
00:00:00.0801152, 0<br />
Concluding: iterating of the array interface is quite some faster than iterating over the IList interface of the same array object. Unfortunately using a.Count in the for loop also does cost some. I hoped the compiler/runtime was smart enough such that it would not cost anything.
Let's add those overloads again now.
Wout
|
|
|
|
|
Of course there will be a performance penalty for using a collection over an array. Even though with generics you can easily implement strongy typed collections (avoiding casting and boxing unboxing), the collections in fact use arrays. They provide you with more flexibility than an array (like you don't need to know the number of elements and they can grow as needed) but basically what it does is array operations.
There are some ways you can improve performance, if you know the number of items you can setup the MaximumLenght property of your collection.
Also, both with arrays and collections, whenever you try to access a member, the CLR will perform a bound check.
but if you access it in a for loop, where you expressely use the .Count, or .Lenght property, the compiler is smart enough to detect that and won't do bound checks with a considerable performance gain (in long running loops).
for example
suppose you have an array a and you want to iteract.
you can do it like this:
int limit = a.Lenght;
for (int i = 0; i < limit; i++)
{
}
this will do a bound check for each iteraction.
if you do
for (int i=0; i < a.Lenght; i++)
{
}
this boundcheck will not be performed.
|
|
|
|
|
The point is that I'm using a typesafe array in any case, not one of the collection flavors. I was just testing out which interface to the typesafe array was quickest. I would have hoped the difference between normal array access and access through IList<double> was minimal, but apparantly it isn't.
Also there seems no performance difference in practise between doing (see measurement results above):
int limit = a.Lenght;
for (int i = 0; i < limit; i++)<br />
{<br />
}
and
for (int i=0; i < a.Lenght; i++)<br />
{<br />
}
Maybe the compiler is smart enough here to optimize the limit variable away...
Wout
|
|
|
|
|
wout de zeeuw wrote: Maybe the compiler is smart enough here to optimize the limit variable away...
I'm not 100% sure but can't a.Length change inside the loop?
So therefore the compiler can't optimize it unless it analyses the whole loop, and I'm guessing that the problems that could occur if it did would outweight the speed advantage.
Ed
|
|
|
|
|
It can indeed (just tested )! So beats me why the two options are equally fast.
Wout
|
|
|
|
|
Because they're both accessing the same type of variable. The a.Length one is simply a property wrapper around an int so in effect they're doing the same thing and hopefully JIT will optimize away the property call if it's just a wrapper, but I'm not so sure
Ed
|
|
|
|
|
I am developing a program that will be used to present song lyrics and texts using a projector, much like Powerpoint can, but my program is specialized and not general like PP.
I have a basic prototype/testing bed ready, and am now starting to code the real program, and in the preparation I will have to decide wich features I will implement.
The program will be written i C# using Windows.Forms and GDI+ and will be released under the GPL license.
What I would like to know is this: I know that it is possible to embed an instance of the Media Player in a Form, but is it possible to use this as a background and then draw shapes and text over it, maybee using a transparent panel? Has anyone done this already?
I thought it was simplier to ask that to start trying it out, even if that is what I will do if I don't get an answer. My guess is that the biggest problem would be flickering from the transparent layer having to be redrawn constantly over the video, wich could maybe be taken care of with double buffering.
Yours Sincerely
/Rickard Haake
Bachelor of Science in Software development, but functioning as a
Youth Minister in the Mission Covenant Church of Sweden
-- modified at 5:05 Monday 20th March, 2006
|
|
|
|
|
Xaake wrote: but is it possible to use this as a background and then draw shapes and text over it, maybee using a transparent panel?
No, it isn't. The MediaPlayer will overdraw every control placed over the top of it. You'd have to use DirectShow and write a custom filter to put the overay test and images into the video stream.
Xaake wrote: wich could maybe be taken care of with double buffering
That would be true if Media Player gave you the opportunity to redraw your controls between every frame, but MediaPlayer doesn't expose such an event. So, no, you can't do this either.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok, Thanks for the answer.
Now I have to decide on either using MDX or sticking with GDI+ and skipping the video background feature
Yours Sincerely
/Rickard Haake
Bachelor of Science in Software development, but functioning as a
Youth Minister in the Mission Covenant Church of Sweden
|
|
|
|
|
Friends,
Is is possible in .NET to safely download and execute a code remotely ? (something like JINI in JAVA)? If yes, then how ?
Imtiaz
|
|
|
|
|
Hello,
I am developing my project, which is 3-tier architecture. I have a doubt in this architecture. As the Data Access component is unavailable to the UI layer, how can I work with the transaction states?
Because, as it is not possible to get the data access procedures are not available at UI layer, it is not possible at UI layer to Begin the transaction state and finally to commit the transation state.
Is it possible to handle the transaction state in the 3-tier architecture? I need your suggestions.
Thanks in advance.
With Regards,
Sheshadrinath.R
|
|
|
|
|
The best would be to handle the transaction entirey from the business layer, as it's all about business logic, not user interaction.
If that is not possible, you can create methods in the business layer for handling the transactions, and expose them to the UI layer. As the UI layer does not directly handle the transactions, it's an acceptable solution.
---
b { font-weight: normal; }
|
|
|
|
|
I am working on a binary clock program and have the logistics worked out and it "seems" to work. The only thing I am having trouble with is how to put it in the system tray over top of the windows clock. I guess I am looking for it to be a "skin" of sorts. So if I double-click on it, it still brings up the Date and Time. Anyone out there know where in the registry/system settings I can change it?
Bowlermonk
|
|
|
|
|
bowlermonk wrote: Anyone out there know where in the registry/system settings I can change it
[chuckles lightly] If only it was that easy! There's nothing in the registry that has anything to to with the clock, save for a single value. This value only specified whether the time will be displayed in 12hr or 24hr format. Nothing more...
Replacing the system tray clock is, by no means, easy. It involves finding the clock's window, getting it's thread, setting a hook to capture messages going to that window (which can't be done in Managed Code!), subclassing the window, and essentially bumping the real clock out of the way and taking over rendering of its window.
You can find a C++ (no .NET) example on SourceForge, I think it's called WinCalendarTime...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the quick respone. I guess I will be coming up with a different idea, rather than the system tray. I tell you, I love this site!
Bowlermonk
|
|
|
|