Custom format axis label - TickLabels

I try to get Custom format axis label for greaph in excel.
chart.ValueAxis.TickLabels.NumberFormat = “hh:mm:ss”; work fine

chart.ValueAxis.TickLabels.NumberFormat = “0 c”; work fine too

but a more complexe
chart.ValueAxis.TickLabels.NumberFormat = “0 gal”; would not work

thank for help


Please zip and attach your template Excel file containing the chart, we will check it soon.

unfortunately I couldn’t , part of secured code .

my question is simple I think and easy to reproduce on any chart


I tried to specify the “0 gal” format against some value in MS Excel but it does not work. Please create your desired sample chart manually in MS Excel with some dummy data for your specified formatting, save the file, now zip the file and attach it. We will check your issue soon.

I try ti have the same result as
sample ex1.png (11.8 KB)
sample ex2.png (2.5 KB)


Thanks for the screenshots.

I used the following sample code with latest version/fix: Aspose.Cells for .NET v20.10.x (please try it if you are not already using it), it works fine and as per your expected screenshot(s):
Sample code:

Workbook wb = new Workbook();
            Worksheet ws = wb.Worksheets.Add("New");
            Style style = wb.CreateStyle();
            style.Name = "DateTimeStyle";
            style.Custom = "dd-mm hh:mm:ss";
            DateTime dt = DateTime.Now;
            ws.Cells[23, 2].PutValue(dt);
            ws.Cells[23, 2].SetStyle(style);
            ws.Cells[24, 2].PutValue(dt.AddHours(1));
            ws.Cells[24, 2].SetStyle(style);
            ws.Cells[25, 2].PutValue(dt.AddHours(2));
            ws.Cells[25, 2].SetStyle(style);
            ws.Cells[26, 2].PutValue(dt.AddHours(3));
            ws.Cells[26, 2].SetStyle(style);
            ws.Cells[27, 2].PutValue(dt.AddHours(4));
            ws.Cells[27, 2].SetStyle(style);
            ws.Cells[28, 2].PutValue(dt.AddHours(5));
            ws.Cells[28, 2].SetStyle(style);
            ws.Cells[29, 2].PutValue(dt.AddHours(6));
            ws.Cells[29, 2].SetStyle(style);
            ws.Cells[23, 3].PutValue(3);
            ws.Cells[24, 3].PutValue(4);
            ws.Cells[25, 3].PutValue(9);
            ws.Cells[26, 3].PutValue(13);
            ws.Cells[27, 3].PutValue(16);
            ws.Cells[28, 3].PutValue(3);
            ws.Cells[29, 3].PutValue(7);
            Chart chart = ws.Charts[ws.Charts.Add(ChartType.ScatterConnectedByLinesWithoutDataMarker, 1, 1, 22, 12)];
            Series aSerie = chart.NSeries[chart.NSeries.Add(String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "D", 24, 30), true)];
            aSerie.XValues = String.Format("{0}!{1}{2}:{1}{3}", ws.Name, "C", 24, 30);
            aSerie.Name = "Date";

            chart.CategoryAxis.TickLabels.NumberFormat = "dd-mm hh:mm;@";
            chart.CategoryAxis.TickLabels.RotationAngle = 45;
            chart.CategoryAxis.TickLabels.Font.Size = 8;
            //chart.ValueAxis.TickLabels.NumberFormat = "0.00";// 
            chart.ValueAxis.TickLabels.NumberFormat = "#,##0.00 \"lutd\"";
            //chart.ValueAxis.MinValue = 0;
            //chart.ValueAxis.MaxValue = 20;
            chart.ValueAxis.Title.Text = "unit";
            chart.Title.Text = "Data" + "\n" + "Test";

            chart.Legend.Position = LegendPositionType.Bottom;           


Please find attached the output file for your reference. (8.5 KB)

By the way, for your line of code (that does not work you mentioned in the first post):

chart.ValueAxis.TickLabels.NumberFormat = “0 gal”;

please change it to:

chart.ValueAxis.TickLabels.NumberFormat = “0 “gal””;

it should work fine.

work thank !


Good to know that your issue is sorted out by the suggested code segment. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.