Dbf to Xls
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Enrico
In my haste to get my problem posted .. I made an error .. the field lengths for the column in question ( reg_no) is C 7 .. any time I run into an alpha-numeric .. here is what happends:
_2306753
200A118_
The _ ( underscore ) represents leeding and trailing spaces .. I do not want the 2nd number behavoir.
I do not understand your "'" syntax ??
Rick Lipkin
In my haste to get my problem posted .. I made an error .. the field lengths for the column in question ( reg_no) is C 7 .. any time I run into an alpha-numeric .. here is what happends:
_2306753
200A118_
The _ ( underscore ) represents leeding and trailing spaces .. I do not want the 2nd number behavoir.
I do not understand your "'" syntax ??
Rick Lipkin
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Right alignment of string containing digits is automatic in Excel:
EMG
Code: Select all
oSheet:Cells( nRow, 1 ):Value := "12345"
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Otherwise, if you want left alignment:
EMG
Code: Select all
oSheet:Cells( nRow, 1 ):Value := "'12345"
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Code: Select all
#define xlRight -4152
FUNCTION MAIN()
LOCAL oExcel, oSheet
oExcel = CREATEOBJECT( "Excel.Application" )
oExcel:WorkBooks:Add()
oSheet = oExcel:ActiveSheet
oSheet:Cells( 1, 1 ):Value = "This is a test"
oSheet:Cells( 2, 1 ):Value = "This is a long test"
oSheet:Cells( 3, 1 ):Value = "12345"
oSheet:Columns( "A:B" ):AutoFit()
oSheet:Columns( "A:B" ):HorizontalAlignment = xlRight
oExcel:Visible = .T.
RETURN NIL
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Enrico
Our SQL loader apparently looks for 'right justification' .. and when it saw some of the alpha-numeric values shifted to the left with a trailing space it failed ..
I have asked our DBA to re-try the latest conversion .. the file 'looks' GREAT'
I will know later this afternoon..
Thanks
Rick Lipkin
Our SQL loader apparently looks for 'right justification' .. and when it saw some of the alpha-numeric values shifted to the left with a trailing space it failed ..
I have asked our DBA to re-try the latest conversion .. the file 'looks' GREAT'
I will know later this afternoon..
Thanks
Rick Lipkin
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Enrico
Bad news .... the loader see's the ( ole ) reg_no column as a double type .. when I ( manually ) take the .dbf table into Excel and then save out as .xls .. the Excel file loads perfectically.
For some odd reason .. Excel formats the reg_no column as numeric even though it containes both charactor and numeric ?? The sql loader is configured a varchar.
Back to square one ..At a loss here.
Rick Lipkin
Bad news .... the loader see's the ( ole ) reg_no column as a double type .. when I ( manually ) take the .dbf table into Excel and then save out as .xls .. the Excel file loads perfectically.
For some odd reason .. Excel formats the reg_no column as numeric even though it containes both charactor and numeric ?? The sql loader is configured a varchar.
Back to square one ..At a loss here.
Rick Lipkin
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Sorry, I don't know what reg_no column is.Rick Lipkin wrote:Enrico
Bad news .... the loader see's the ( ole ) reg_no column as a double type ..
Then, as I previously said, try to prefix it with a single quote "'".Rick Lipkin wrote:For some odd reason .. Excel formats the reg_no column as numeric even though it containes both charactor and numeric ?? The sql loader is configured a varchar.
EMG
You can set the cell format to text before adding the data. Then it will not have mixed numberic and text
I believe you can add the following before you add data.
By the way, here is a good way to find out how to do something in Excel.
Start macro record, perform the action, stop macro, then look at the code that is created.
I believe you can add the following before you add data.
Code: Select all
oSheet:Range( "A:A" ):Set( "NumberFormat", '@' )
// then the follwing would be text and not numeric
oSheet:Cells( 1, 1 ):Value = "12345"
Start macro record, perform the action, stop macro, then look at the code that is created.
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
James
Ultimately I want to use SQLRDD on this application and move the .dbf's to MS SQL Server..
I have seen the dbf2sql but that utility does not support MS Sql Server
This app needs to have outside Web data verification and will eventually need to be moved to SQL .. politics and complications need to be over-come first .. the quickest and easiest way to acomplish this task was to replicate the data to the Web Server..
Ron mentioned that SQLRDD was going to be sold seperately in the next release of xHarbour and not specifically bundled with the builder.. I am waiting to see that come about and have a go at moving the back end to SQL with ( minimal ) code changes ..
We'll see
Rick
Ultimately I want to use SQLRDD on this application and move the .dbf's to MS SQL Server..
I have seen the dbf2sql but that utility does not support MS Sql Server
This app needs to have outside Web data verification and will eventually need to be moved to SQL .. politics and complications need to be over-come first .. the quickest and easiest way to acomplish this task was to replicate the data to the Web Server..
Ron mentioned that SQLRDD was going to be sold seperately in the next release of xHarbour and not specifically bundled with the builder.. I am waiting to see that come about and have a go at moving the back end to SQL with ( minimal ) code changes ..
We'll see
Rick
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Gale
The pre-formatting seemd to work with the column justification of the mixed data .. and it formatted the column to 'text" rather than 'general' as before ..
I have the new table in the staging area for the DBA to test .. we'll see in the morning ..
Thanks .. this has been an interesting learning experience.
Rick Lipkin
The pre-formatting seemd to work with the column justification of the mixed data .. and it formatted the column to 'text" rather than 'general' as before ..
I have the new table in the staging area for the DBA to test .. we'll see in the morning ..
Thanks .. this has been an interesting learning experience.
Rick Lipkin