Solved

How to numberformat a column in excel from delphi

Posted on 2004-03-24
13
2,649 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
  • 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
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!

 
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

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!

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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