• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2832
  • Last Modified:

How to numberformat a column in excel from delphi

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
ashdata
Asked:
ashdata
  • 5
  • 4
1 Solution
 
shaneholmesCommented:
I belive there is a FixedDecimalPlaces which you can pass the column ID

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

Shane
0
 
shaneholmesCommented:
Sorry,

maybe its something like this

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

Shane
0
 
ashdataAuthor Commented:
Thansk, Compiles and runs but gets "old format or invalid type library" when gets to that line ??
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
shaneholmesCommented:
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
 
ashdataAuthor Commented:
Delphi 7 and Office 2002
0
 
shaneholmesCommented:
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
 
ashdataAuthor Commented:
Thanks, very frustrating as that sounded perfect :(
0
 
shaneholmesCommented:
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
 
ashdataAuthor Commented:
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
 
arodionovCommented:
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

Industry Leaders: 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!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now