Style.Custom problem

Hi

I am having problems formatting cells where the data is a duration. When I use the following code:

cell.PutValue("0:24:34");

cell.Style.Custom="Cool [H]:mm:ss";

the generated Exel worksheet displays the data as "00:24:34" (it should be "0:24:34"), and when I examine the cell's format it is of type Number (-1234).

Ultimately I will have a column of these durations and I will need to create a formula to sum them and display that sum also in Cool [H]:mm:ss format.

Do you know what I am doing wrong?

Thanks

Alan

1. Number format won't take effect on cell which contains string. So if your code is:

cells["A1"].PutValue("0:24:34");
cells["A1"].Style.Custom = " [ h ] :mm:ss";

It should display "0:24:34".

2. If you put a numeric value to cell A1 and wish to display it as 0:24:34, you should set the custom string as:

cells["A1"].Style.Custom = "h:mm:ss";

Laurence:

Thank you - that works fine.

Alan