dbTalk Databases Forums  

Data Transform to Excel - apostrophe

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


Discuss Data Transform to Excel - apostrophe in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Liz
 
Posts: n/a

Default Data Transform to Excel - apostrophe - 11-04-2003 , 10:08 AM






When I export numeric fields to excel using a Data
Transform task the fields become text with an apostrophe.
What is the best method for handling this? Currently I am
copying a blank spreadsheet then exporting the data. Can I
use an Active X script to format the columns in Excel? If
so, please provide example code.

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

Default Re: Data Transform to Excel - apostrophe - 11-04-2003 , 10:46 AM






One way of doing it would be to use a Macro then formats the cells. The
beauty of this is you can do it in Excel and simply Record and Save the
Macro. You can call it from an Active Script task using code similar to

Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet

SET xl_app = CREATEOBJECT("Excel.Application")

SET xl_spreadsheet = xl_app.Workbooks.Open _
(DTSGlobalVariables("gv_str_SpreadsheetName").Valu e)


'Run the macro

xl_app.Run DTSGlobalVariables("gv_str_Macroname").Value


'Very important to clean up.
'if you make changes to a spreadsheet then XL will ask you if you want to
save
'it on closing so let's pre-empt it and save the workbook then close

xl_spreadsheet.Save

xl_spreadsheet.Close

xl_app.Quit
set xl_app = Nothing

Main = DTSTaskExecResult_Success
End Function


You may also like to explicitly CAST() the column as an integer.


--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Liz" <elizabeth.gann (AT) suntrust (DOT) com> wrote

Quote:
When I export numeric fields to excel using a Data
Transform task the fields become text with an apostrophe.
What is the best method for handling this? Currently I am
copying a blank spreadsheet then exporting the data. Can I
use an Active X script to format the columns in Excel? If
so, please provide example code.



Reply With Quote
  #3  
Old   
 
Posts: n/a

Default Re: Data Transform to Excel - apostrophe - 11-04-2003 , 11:13 AM



Alan:

Thanks, I already had that example code. Here is a
solution I got from Excel help to be used in a Macro.

In an empty cell, enter the number 1.
Select the cell, and on the Edit menu, click Copy.
Select the range of numbers stored as text you want to
convert.
On the Edit menu, click Paste Special.
Under Operation, click Multiply.
Click OK.
Delete the content of the cell entered in the first step.


Quote:
-----Original Message-----
One way of doing it would be to use a Macro then formats
the cells. The
beauty of this is you can do it in Excel and simply
Record and Save the
Macro. You can call it from an Active Script task using
code similar to

Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet

SET xl_app = CREATEOBJECT("Excel.Application")

SET xl_spreadsheet = xl_app.Workbooks.Open _
(DTSGlobalVariables
("gv_str_SpreadsheetName").Value)


'Run the macro

xl_app.Run DTSGlobalVariables("gv_str_Macroname").Value


'Very important to clean up.
'if you make changes to a spreadsheet then XL will ask
you if you want to
save
'it on closing so let's pre-empt it and save the
workbook then close

xl_spreadsheet.Save

xl_spreadsheet.Close

xl_app.Quit
set xl_app = Nothing

Main = DTSTaskExecResult_Success
End Function


You may also like to explicitly CAST() the column as an
integer.


--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"Liz" <elizabeth.gann (AT) suntrust (DOT) com> wrote in message
news:4b7801c3a2ed$f4e73d90$7d02280a (AT) phx (DOT) gbl...
When I export numeric fields to excel using a Data
Transform task the fields become text with an
apostrophe.
What is the best method for handling this? Currently I
am
copying a blank spreadsheet then exporting the data.
Can I
use an Active X script to format the columns in Excel?
If
so, please provide example code.


.


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.