ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 2nd, 2012, 07:48 AM
Abnaxus78 Abnaxus78 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 13 Abnaxus78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 43 m 54 sec
Reputation Power: 0
Cfspreadsheet and leading zeros in cells

Hi guys,

i'm trying to export a query into an xls file. everything is working as it should and i get the xls file but there is a problem with a column that contains leading zeros ( i.e 022334).

I want to keep those zeros but it appears cfspreadsheet creates a new xls file with a cell format of "General" so that removes the leading zeros.

using SpreadsheetFormatColumns to change the dataformat to "text" doesn't help since the leading zeros have already dissapeared.

any thoughts on how to fix this problem.?

Reply With Quote
  #2  
Old November 2nd, 2012, 10:25 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
This one I'm afraid I can't help with, as I haven't used cfspreadsheet much. If no one else can chime in, I'd try Google or possibly the CF forums at Adobe.com.

Reply With Quote
  #3  
Old November 2nd, 2012, 10:04 PM
jbird4k's Avatar
jbird4k jbird4k is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Location: Maryland
Posts: 74 jbird4k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 46 m 58 sec
Reputation Power: 12
I would convert the field to text in your query before sending the rs to cfspreadsheet. This works especially well with date fields, I have an oracle backend and formatting dates using cfspreadsheet function was a crap shoot as to the output. formatting the data in the rs cleared that up.

hope this helps
__________________
J. Birdsell,

Reply With Quote
  #4  
Old November 5th, 2012, 01:32 AM
Abnaxus78 Abnaxus78 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 13 Abnaxus78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 43 m 54 sec
Reputation Power: 0
@jbird4k what exactly do you mean by "convert the field to text in your query ".?

The field is already a text field .The issue appears when storing into the xls file for the reason i mentioned above ( General dataformat vs Text in Excel).

I have found this link http://cfsimplicity.com/16/forcing-values-to-be-inserted-into-spreadsheets-as-text but i have not tested it yet.

I'll let you know when i do.

Reply With Quote
  #5  
Old November 5th, 2012, 04:53 AM
Abnaxus78 Abnaxus78 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 13 Abnaxus78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 43 m 54 sec
Reputation Power: 0
Update: Ok guys. everything worked using the above solution.

It's not the best solution since you
save your query in the excel file.
change the column in the excel that contains the leading zeros dataformat to text.
re-write everything using SpreadsheetSetCellValue in order to avoid reusing cfspreadsheet.

Reply With Quote
  #6  
Old November 6th, 2012, 02:28 PM
cfSearching cfSearching is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 117 cfSearching User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 16 m 2 sec
Reputation Power: 6
Unfortunately that may be as good as it gets. CF9 has a several formatting related bugs, some of which were fixed in 9.0.1. FWIW, CF10 does preserve the zeroes:

Code:
<cfset qry = queryNew("")>
<cfset queryAddColumn(qry, "MyColumn", "varchar", listToArray("02222,01111"))>
<cfset sheet = spreadSheetNew()>
<cfset SpreadsheetFormatColumn(sheet,{dataFormat="@"},1)>
<cfset SpreadSheetAddRows(sheet, qry)>
<cfset SpreadSheetWrite(sheet, "c:/path/to/someFile.xls", true)>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Cfspreadsheet and leading zeros in cells

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap