Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Custom number format [hh]:mm:ss

$
0
0
I'm trying to set a cell with custom number format code [hh]:mm:ss so that the visible value always follows an hr:min:sec format. The cell value is set to a string which is in this format (for example, "12:00:00"). Everything seems to work until the hours value is greater than 24.

Here's the code I'm using to create the spreadsheet:
for(int i = 0; i < output.Count; i++)
            {
                newCol.Cell(ExcelRowStart + i).Value = output[i];

                if (Regex.Match(output[i], "\\d{2,}.\\d{2,}.\\d{2,}").Success)
                {
                    newCol.Cell(ExcelRowStart + i).Style.NumberFormat.Format = "[hh]:mm:ss";
                }
            }
Here's an image of the result where I increment the hour value by 1 for each row:

Image

What can I do to get this to display like I want?

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>