Solved

How to numberformat a column in excel from delphi

Posted on 2004-03-24
13
2,665 Views
Last Modified: 2012-06-22
I am exporting repor data to excel but need to set the numberformat to "0.00" for 2 decimal places for certain columns.

I can do this via              

VarXCel.Range['E1','E99'].Numberformat:='0.00';

if I know how many rows there are but surely there must be a way of specifying simple the whole column irrespective of how many rows are in use.  
0
Comment
Question by:ashdata
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
13 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10670538
I belive there is a FixedDecimalPlaces which you can pass the column ID

 ExcelApplication1.FixedDecimalPlaces[3]:= '0.00';

Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10670555
Sorry,

maybe its something like this

 ExcelApplication1.FixedDecimal[3]:= True;
  ExcelApplication1.FixedDecimalPlaces[3]:= 2;

Shane
0
 

Author Comment

by:ashdata
ID: 10670664
Thansk, Compiles and runs but gets "old format or invalid type library" when gets to that line ??
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:shaneholmes
ID: 10670704
What version of Delphi are you using? SOunds like its not compatible with the version of the Excell OLE server you have installed on your machine

Shane
0
 

Author Comment

by:ashdata
ID: 10670729
Delphi 7 and Office 2002
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10670805
hmm,
not exactly sure what is going on there.

I do know that is how you change the column precision though.

I have used it in the past .

Shane
0
 

Author Comment

by:ashdata
ID: 10670876
Thanks, very frustrating as that sounded perfect :(
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10670940
Have you tried different values in there in both places (play with it abit) see if it will accept any otehr them the values you are using.

Shane
0
 

Author Comment

by:ashdata
ID: 10671140
Still no luck. Given other formatting requirement eg text to stop thinking it is numeric etc, I need to be able to set the format for columns other than decimals - so back to the oringinal problem :( In the mean time I will do the range technique...
0
 

Accepted Solution

by:
arodionov earned 50 total points
ID: 10675470
Hello.

I didn't solve such a problem but I have just recorded a macro in Excel while selecting a whole column and found the following VB code:

Columns("D:D").Select

Maybe it will work...
Anyway the Columns property exists in ExcelApplication interface declaration.

Alex.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question