dbTalk Databases Forums  

Transfering data into excel

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Transfering data into excel in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sjambulapati via SQLMonster.com
 
Posts: n/a

Default Transfering data into excel - 04-03-2006 , 02:12 PM






Hi,,


I am using activex task in my dts, creating excel file with multiple
woksheets.

I want to create more than 3 worksheets in a workbook.

it is limiting to 3 worksheets.

here is my code



Dim oExcel
Dim oBook
Dim oSheet
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add

'Add data to cells of the first worksheet in the new workbook
Set oSheet = oBook.Worksheets(1)
oSheet.name = "AC19_COUNT"
Set oSheet = oBook.Worksheets(2)
oSheet.name = "POAMOUNT_NOMATCH"

Set oSheet = oBook.Worksheets(3)
oSheet.name = "RT1001_PO_NOTIN_FAMMS"
Set oSheet = oBook.Worksheets(4)
oSheet.name = "DuplicateCardNumber"


'Save the Workbook and Quit Excel
oBook.SaveAs"c:\temp\" oExcel.Quit

Any suggestions please

--
Message posted via http://www.sqlmonster.com

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Transfering data into excel - 04-03-2006 , 03:33 PM






Hello sjambulapati via SQLMonster.com,

What do you intend to do with those Worksheets?

In DTS you can issue a CREATE TABLE statement against the Spreadsheet connection
to Create a Worksheet/Named Range. If this is not what you intend to do
then maybe an XL newsgroupd will be able to help you more than this one.


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

Quote:
Hi,,

I am using activex task in my dts, creating excel file with multiple
woksheets.

I want to create more than 3 worksheets in a workbook.

it is limiting to 3 worksheets.

here is my code

Dim oExcel
Dim oBook
Dim oSheet
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook
Set oSheet = oBook.Worksheets(1)
oSheet.name = "AC19_COUNT"
Set oSheet = oBook.Worksheets(2)
oSheet.name = "POAMOUNT_NOMATCH"
Set oSheet = oBook.Worksheets(3)
oSheet.name = "RT1001_PO_NOTIN_FAMMS"
Set oSheet = oBook.Worksheets(4)
oSheet.name = "DuplicateCardNumber"
'Save the Workbook and Quit Excel
oBook.SaveAs"c:\temp\" oExcel.Quit
Any suggestions please




Reply With Quote
  #3  
Old   
sjambulapati via SQLMonster.com
 
Posts: n/a

Default Re: Transfering data into excel - 04-03-2006 , 04:22 PM



Hi

thank you

I using recordset objects . Each results are exported to a excel file in
different worksheets.

here is my Code



Dim oExcel
Dim oBook
Dim oSheet
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook
Set oSheet = oBook.Worksheets(1)
oSheet.name = "AC19_COUNT"
Dim fldCount
Dim recCount1
Dim iCol
Dim iRow
fldCount =EXCEL1.Fields.Count
For iCol = 1 To fldCount
osheet.Cells(1, iCol).Value = EXCEL1.Fields(iCol - 1).Name
Next
osheet.Cells(2, 1).CopyFromRecordset EXCEL1
Set oSheet = oBook.Worksheets(2)
oSheet.name = "POAMOUNT_NOMATCH"
fldCount =EXCEL2.Fields.Count
For iCol = 1 To fldCount
osheet.Cells(1, iCol).Value = EXCEL2.Fields(iCol - 1).Name
Next


osheet.Cells(2, 1).CopyFromRecordset EXCEL2
Set oSheet = oBook.Worksheets(3)
oSheet.name = "RT1001_PO_NOTIN_FAMMS"
fldCount =EXCEL5.Fields.Count

For iCol = 1 To fldCount
osheet.Cells(1, iCol).Value = EXCEL5.Fields(iCol - 1).Name
Next


osheet.Cells(2, 1).CopyFromRecordset EXCEL5


'Set oSheet = oBook.Worksheets(4)
'oSheet.name = "DUPLICATE CARD NUMBER"

' fldCount =EXCEL3.Fields.Count
' For iCol = 1 To fldCount
' osheet.Cells(1, iCol).Value = EXCEL3.Fields(iCol - 1).Name
' Next


' osheet.Cells(2, 1).CopyFromRecordset EXCEL3


I am getting Subscript Outof range Error


thanks

Allan Mitchell wrote:
Quote:
Hello sjambulapati via SQLMonster.com,

What do you intend to do with those Worksheets?

In DTS you can issue a CREATE TABLE statement against the Spreadsheet connection
to Create a Worksheet/Named Range. If this is not what you intend to do
then maybe an XL newsgroupd will be able to help you more than this one.

Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

Hi,,

[quoted text clipped - 24 lines]
oBook.SaveAs"c:\temp\" oExcel.Quit
Any suggestions please
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums...r-dts/200604/1


Reply With Quote
  #4  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Transfering data into excel - 04-03-2006 , 04:50 PM



Hello sjambulapati via SQLMonster.com,

If you are using Recordsets then can you not use the method I described
whereby you create the Excel Tbale/Named range in an ExecuteSQL task forst
anf then pump data to it???



Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

Quote:
Hi

thank you

I using recordset objects . Each results are exported to a excel file
in different worksheets.

here is my Code

Dim oExcel
Dim oBook
Dim oSheet
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook
Set oSheet = oBook.Worksheets(1)
oSheet.name = "AC19_COUNT"
Dim fldCount
Dim recCount1
Dim iCol
Dim iRow
fldCount =EXCEL1.Fields.Count
For iCol = 1 To fldCount
osheet.Cells(1, iCol).Value = EXCEL1.Fields(iCol - 1).Name
Next
osheet.Cells(2, 1).CopyFromRecordset EXCEL1
Set oSheet = oBook.Worksheets(2)
oSheet.name = "POAMOUNT_NOMATCH"
fldCount =EXCEL2.Fields.Count
For iCol = 1 To fldCount
osheet.Cells(1, iCol).Value = EXCEL2.Fields(iCol - 1).Name
Next
osheet.Cells(2, 1).CopyFromRecordset EXCEL2
Set oSheet = oBook.Worksheets(3)
oSheet.name = "RT1001_PO_NOTIN_FAMMS"
fldCount =EXCEL5.Fields.Count
For iCol = 1 To fldCount
osheet.Cells(1, iCol).Value = EXCEL5.Fields(iCol - 1).Name
Next
osheet.Cells(2, 1).CopyFromRecordset EXCEL5

'Set oSheet = oBook.Worksheets(4)
'oSheet.name = "DUPLICATE CARD NUMBER"
' fldCount =EXCEL3.Fields.Count
' For iCol = 1 To fldCount
' osheet.Cells(1, iCol).Value = EXCEL3.Fields(iCol - 1).Name
' Next
' osheet.Cells(2, 1).CopyFromRecordset EXCEL3

I am getting Subscript Outof range Error

thanks

Allan Mitchell wrote:

Hello sjambulapati via SQLMonster.com,

What do you intend to do with those Worksheets?

In DTS you can issue a CREATE TABLE statement against the Spreadsheet
connection to Create a Worksheet/Named Range. If this is not what
you intend to do then maybe an XL newsgroupd will be able to help you
more than this one.

Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com
Hi,,

[quoted text clipped - 24 lines]

oBook.SaveAs"c:\temp\" oExcel.Quit
Any suggestions please



Reply With Quote
  #5  
Old   
sjambulapati via SQLMonster.com
 
Posts: n/a

Default Re: Transfering data into excel - 04-04-2006 , 08:58 AM



Any example code please
It is working good up to three sheets ,after that i am getting subscript out
of range error

Thanks


Allan Mitchell wrote:
Quote:
Hello sjambulapati via SQLMonster.com,

If you are using Recordsets then can you not use the method I described
whereby you create the Excel Tbale/Named range in an ExecuteSQL task forst
anf then pump data to it???

Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

Hi

[quoted text clipped - 68 lines]
oBook.SaveAs"c:\temp\" oExcel.Quit
Any suggestions pleas
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums...r-dts/200604/1


Reply With Quote
  #6  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Transfering data into excel - 04-04-2006 , 02:15 PM



Hello sjambulapati via SQLMonster.com,


In an ExecuteSQL task use the XL Connection Manager and issue different CREATE
TABLE statements. You should be able to make more than 3 worksheets.



Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

Quote:
Any example code please
It is working good up to three sheets ,after that i am getting
subscript out
of range error
Thanks

Allan Mitchell wrote:

Hello sjambulapati via SQLMonster.com,

If you are using Recordsets then can you not use the method I
described whereby you create the Excel Tbale/Named range in an
ExecuteSQL task forst anf then pump data to it???

Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com
Hi

[quoted text clipped - 68 lines]

oBook.SaveAs"c:\temp\" oExcel.Quit
Any suggestions pleas



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.