|
I'm assuming you already have Excel interop code written that creates the worksheet.
All you do is create a new Workbook, add a new Worksheet to it, populate it, and save. Rinse and Repeat.
Google results for "vb.net create new workbook"[^].
|
|
|
|
|
Dave Kreskowiak:
Thank you for your immediate response. However my question is can I reuse the excel object embedded in the vb.net 2005 desktop application? I need to put the output from sql server 2005 on separate spreadsheets for different customers. To accomplish this tak, it looks like I need to close and reopen the excel object each time I need to write to a new excel worksheet. Thus is there a way that I could reuse the object?
Thanks!
|
|
|
|
|
jazzgirl wrote: can I reuse the excel object
Yes.
jazzgirl wrote: it looks like I need to close and reopen the excel object each time I need to write to a new excel worksheet.
Not true. You just close the existing workbook after you save it and create a new workbook, then add a new worksheet to it.
jazzgirl wrote: is there a way that I could reuse the object?
The simplest route, though no the most proper, would be to just create a class-level variable to hold the Excel app object, then you can use it through out the form class.
|
|
|
|
|
Hi I programmed Xcell Object in VB6 , and Here is My Idea ,How it works , it may not be
much different from VB-Net Code :
To Read from a specific cell on the Sheet --> to a variable use following Formats :
-----------------------------------------------------------------------------------
NUM = Val(Form1.Spreadsheet1.Cells(9, 5))
BRN = Val(Form1.Spreadsheet1.Cells(10, 5))
And To Write a value from a Variable to a Spesific Cell on a sheet Use Format below :
----------------------------------------------------------------------------------------
MM = 4 :' Say or any other value.
Form1.Spreadsheet1.Cells(MM + 3, 1) = MM
-----------------------------------------------------------------------------------------
If You are in Sheet1 and you want to send Output to sheet3 , this is Simple, Just Change
the sheet # and provide the Cell adress exactly as an example see :
JK ... has some value send it to sheet3 :
Form1.Spreadsheet3.Cells(7, 5) = JK
I hope I helped .
Regards , mohamad
|
|
|
|
|
hello every one
i want to create a report in excel using the items and sub items of listview
my code is:-
Dim xl As New Excel.Application
Private Sub exc()
Try
Dim i As String
i = CStr(1)
Me.xl = CreateObject("Excel.Application")
Me.xl.Workbooks.Add()
Me.xl.Range("A1").Value = "Sr No."
Me.xl.Range("B1").Value = "Area Code"
Me.xl.Range("C1").Value = "Area Name"
Me.xl.Range("D1").Value = "Alias"
i = CStr(2)
'Me.TextBox1.Focus()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
this i have written in form Load event
now code on button click event is:-
Private Sub btnreport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnreport.Click
Try
xl.Visible = True
Me.xl.Range("A" & i).Value = Me.lst1.Items(0).SubItems(0).Text
Me.xl.Range("B" & i).Value = Me.lst1.Items(0).SubItems(3).Text
Me.xl.Range("C" & i).Value = Me.lst1.Items(0).SubItems(1).Text
Me.xl.Range("D" & i).Value = Me.lst1.Items(0).SubItems(2).Text
i = CStr(CDbl(i) + 1)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Exception from HRESULT: 0x800A03EC
i got this message in catch block cant get it so
please help..
|
|
|
|
|
As far as I can see, i needs to equal 1 for this to work ? Have you stepped through the code to see what is blowing up ? Have you googled the HRESULT ? Is that all the error message you get ?
I googled the HRESULT and this was the first hit:
http://www.ureader.com/message/692318.aspx
you really need to learn to do basic research.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i give u full code aft one to two days ok
dinesh rajput
global infotec
Mohali
Punjab
India
dinua1091@rediffmail.com
|
|
|
|
|
hello
Mr. Rajput
it will be kind of u if u give me code...
thanks a lot in advance...
|
|
|
|
|
I have not used vb is about 15 years, I was wondering what I needed to do to get my program to allow me to pick a directory and load 3 dbf files in to the program so I can modify them if some one can point me in the right direction that would be great
|
|
|
|
|
seccard1 wrote: I have not used vb is about 15 years,
wow, Is that mean the last version you use was VB3.0? It was released around 1993. What made you come back?
seccard1 wrote: I was wondering what I needed to do to get my program to allow me to pick a directory and load 3 dbf files in to the program so I can modify them if some one can point me in the right direction that would be great
You are trying to read dbase databse? here is what you need
Add Microsoft DAO reference to your project then the following code will do some magic tricks
Dim sql As String
sql = "Select * From table"
Dim db As Datbase
Set db = DBEngine.OpenDatabase("C:\Database", False, False, "dBASE III;")
Dim recset As RecordSet
Set recset= db.OpenRecordset(sql)
This is may not compile, you will need to tweak it. It has been that long since working with vb
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
I used to use VB 3.0 Professional loads a while ago
Lloyd J. Atkinson
I used Vista the other day. It was also the last time I will ever voluntarily use the damn thing. I would rather use Windows 1.0 just because it dosent literally chew the RAM just to draw pretty colours.
|
|
|
|
|
hello every one
I want that all the items of checklistbox which are checked to be entered in multiline textbox...for that my code is:-
Dim i, t As Integer
t = Me.chklistbox.Items.Count
For i = 0 To t - 1
Me.txtpov.Text = (Me.chklistbox.CheckedItems(i) & "," & Me.chklistbox.CheckedItems(i + 1))
Next
but this only works for two items rest are not seen
so please tell what shall i write in code to display every item that is checked comes in multiline textbox....
|
|
|
|
|
Hi,
a property that gets several values assigned to it only remembers the last value, so having Me.txtpov.Text = something in a loop like that does not make sense. Either use a Control that knows how to collect multiple items, or concatenate all strings you want to be shown.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Dim i, t As Integer
t = Me.chklistbox.CheckedItems.Count
For i = 0 To t - 1
Me.txtpov.Text = Me.txtpov.Text & Me.chklistbox.CheckedItems(i) + ","
Next
* You were counting all the items in your loop, whilst you only want to iterate through the checked ones.
* You were overwriting your textbox with the text of the last two items found, whilst you want to append text to the textbox, for each checked item.
Enjoy
I are troll
|
|
|
|
|
hi
the code u suggested works thank you very much...
but problem is that all the items are added to multiline textbox after i click save button..
for eg:-
if i tick on item 'a' of checklistbox and then click on save button that item appears in multiline textbox now suppose i again tick on item 'b' in checklistbox and than click save button at this item 'a' is again added to multiline text box so the outcome is 'a','a','b' which means repetation of 1st item this happens every time i click on save button...
my code is:-
Private Sub btnsave2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave2.Click
Try
If Me.chklistbox.SelectedIndex = -1 Then
MsgBox("nothing selected")
Exit Sub
End If
Dim i, t As Integer
t = Me.chklistbox.Items.Count
For i = 0 To t - 1
Me.txtpov.Text = Me.txtpov.Text & Me.chklistbox.CheckedItems(i) + ","
Next
Catch ex As Exception
ex.ToString()
End Try
End Sub
please suggest what shall i do to clear multiline textbox before saving it...
|
|
|
|
|
Try
If Me.chklistbox.SelectedIndex = -1 Then
MsgBox("nothing selected")
Exit Sub
End If
Dim i, t As Integer
Me.txtpov.Text.Clear()
t = Me.chklistbox.Items.Count
For i = 0 To t - 1
Me.txtpov.Text = Me.txtpov.Text & Me.chklistbox.CheckedItems(i) + ","
Next
Catch ex As Exception
ex.ToString()
End Try
I are troll
|
|
|
|
|
hi
thanks for your suggestion the code you gave is working..
but the content is displayed in single line
can u please suggest what shall i do to display it in next line..
i mean after ','i want it to be displayed in next line...
i m beginner so please help....
|
|
|
|
|
Try
If Me.chklistbox.SelectedIndex = -1 Then
MsgBox("nothing selected")
Exit Sub
End If
Dim i, t As Integer
Me.txtpov.Text.Clear()
t = Me.chklistbox.Items.Count
For i = 0 To t - 1
Me.txtpov.Text = Me.txtpov.Text & Me.chklistbox.CheckedItems(i) + Environment.NewLine
Next
Catch ex As Exception
MessageBox(ex.ToString())
End Try
I are troll
|
|
|
|
|
|
u concenate to character where is find , or '' and than match to database if find than no update this else update data base
but i can't understand which type of application u devloped
warm regard
dinesh rajut
global infotec
India
dinua1091@rediffmail.com
|
|
|
|
|
Hi,
How can I use { in my string.Format?(it's part of my string) and & _ for contacting string. In below code it says 'Input string is not in correct Format':
<br />
String.Format("function (s,e){if(e.item.name == 'OtherField'){if(" & _<br />
"'{0}'.IsCustomizationWindowVisible() == false){" & _<br />
"'{0}'.ShowCustomizationWindow()} else{" & _<br />
"'{0}'.HideCustomizationWindow()}" & "}else if(e.item.name == 'Group'){" & _<br />
"if(e.item.GetChecked()){'{0}'.PerformCallback()}}}", Me.ClientInstanceName)<br />
Best wishes
|
|
|
|
|
Search on 'Escaping Braces'.
That should give you the start you require.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Experts,
I have a SAP RFC (Remote Function Call) which is being called from VB6 code. Being a ABAPer I dont have knowledge of VB programming. I would be thankful if someone give me code for passing table name to SAP RFC.
********My RFC is as given below
CALL FUNCTION 'ZTEST_RFC'
TABLES
IT_RFCTABLE = VB_TABLE_NAME????
EXCEPTIONS
NOT FOUND = 1
INSERT_FAILURE = 2
OTHERS = 3.
I need to pass a table from my VB6 code and my data is stored in SQL2000.
Even the code from .NET will be welcome.
Thanks in advance.
modified on Saturday, March 28, 2009 1:44 PM
|
|
|
|
|
Without seeing the code you have now, I can olnyl make assumptions (bad idea!) about what you're after. Something like this maybe:
Dim queryString as String
queryString = "CALL FUNCTION 'ZTEST_RFC' TABLES " & _
"IT_RFCTABLE = " & tableName & " EXCEPTIONS " & _
"NOT FOUND = 1 INSERT_FAILURE = 2 OTHERS = 3."
I have no idea if this string is going to work becuase I've never written code for SAP RFC.
|
|
|
|
|
Hi,
I am tryign to play a MP3 file via mcisendtring. However, it doesn't play anything. I couldn't figure out what is causing it. It doesn't give me any error message and it doesn't play it also. If you know the problem, would you please let me know.
Thank you.
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Class Player
Private isOpen As Boolean = False
Private GetFileName As String = Nothing
'mciSendString
<[DllImport]("winmm.dll")> _
Private Shared Function mciSendString(ByVal command As String, ByVal ReturnValue As StringBuilder, _
ByVal returnLength As Integer, ByVal winHandle As IntPtr) As Long
End Function
'This procedure closes the playing media file
Public Sub ClosePlayer()
If (isOpen) Then
Dim PlayCommand As String = "Close " + GetFileName
mciSendString(PlayCommand, Nothing, 0, IntPtr.Zero)
isOpen = False
End If
End Sub
'This procedure will open the media file
Private Sub OpenMediaFile()
ClosePlayer()
Dim PlayCommand As String = "open \""" + GetFileName + " \ "" type mpegvideo alias MediaFile"
mciSendString(PlayCommand, Nothing, 0, IntPtr.Zero)
isOpen = True
End Sub
'This sub procedure will play the media file
'
Private Sub PlayMediaFile()
If (isOpen) Then
Dim PlayCommand As String = "play " + GetFileName
mciSendString(PlayCommand, Nothing, 0, 0)
End If
End Sub
'This sub procedure will initiate playing
Public Sub Play(ByVal FileName As String)
GetFileName = fileName
OpenMediaFile()
PlayMediaFile()
End Sub
'this procedure will pause the file
'
Public Sub Pause()
mciSendString("pause " + GetFileName, Nothing, 0, IntPtr.Zero)
End Sub
'This sub procedure will resume the file
'
Public Sub Resumit()
mciSendString("resume " + GetFileName, Nothing, 0, 0)
End Sub
End Class
Dim playclass as new Player
playclass.play("hello.mp3")
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|