When using aspose.cells to save an Excel workbook to a PDF, the chart unit label are displayed as “Millions” in English. How can I set it to display Millions in Chinese(百万)?
image.png (40.2 KB)
When using aspose.cells to save an Excel workbook to a PDF, the chart unit label are displayed as “Millions” in English. How can I set it to display Millions in Chinese(百万)?
image.png (40.2 KB)
To change the chart unit label from “Millions” to “百万” (Millions in Chinese) when saving an Excel workbook to a PDF using Aspose.Cells, you can set the culture information for the workbook. Here’s how to do it:
// Load your workbook
Workbook workbook = new Workbook("yourfile.xlsx");
// Set the culture to Chinese (Simplified)
workbook.Settings.CultureInfo = new System.Globalization.CultureInfo("zh-CN");
// Save the workbook to PDF
workbook.Save("output.pdf", SaveFormat.Pdf);
By setting the CultureInfo to “zh-CN”, the chart unit labels should display in Chinese. Ensure to replace "yourfile.xlsx" with the path to your actual Excel file.
If you have any further questions or need additional assistance, feel free to ask!
You may define a class that inherit from ChartGlobalizationSettings. Then, by rewriting the related functions, you can set the text of the chart elements in your own language. For complete reference see document with example code: Convert Chart to Image for Chinese Region|Documentation
Hope, this helps a bit.
Now it displays normally when saved as a PDF file, but when saved as an Excel file(xlsm), “HundredMillions” still shows as “x100000000”. How can we make it display as “亿” instead?
It’s good to hear that after applying the chart’s globalization settings, it is now rendering to PDF as per your expectations.
Could you please let us know if you are using Chinese locale/regional settings or something else when viewing the output Excel file in MS Excel? What is the language setting set for your Excel? Additionally, it would be appreciated if you could share the input Excel file (if available), the output Excel file generated by Aspose.Cells, and a complete runnable sample code to replicate the issue. Furthermore, please provide a sample Excel file containing the chart with your desired unit labels in Chinese. We will review your issue/requirements soon.
PS. please zip the Excel files and other resource prior attaching here.
Thank you for your reply. I use MS Excel with the Chinese environment settings. The language used is Chinese. The input, output files and sample code can be found in the zip file. I expect that the unit labels of both my Excel output file and the PDF output file will be same and three sheets chart unit_label display in Chinese. thanks!
aspose_evaluation.zip (8.0 MB)
Thanks for the sample files and sample app.
We will look into your requirements and get back to you with our recommendations or code snippets.
For the chart where the value of the unit label text has been custom-set to “亿”, when Aspose saves the Excel file, set it to the default value “x100000000”, is this a bug?
Even if I modify the unit label text in the program as shown below, after saving as an xlsx file, the unit label text of the chart will still be displayed as "x100000000".
if(cht.ValueAxis.DisplayUnit.ToString() == "HundredMillions")
{
cht.ValueAxis.DisplayUnitLabel.IsAutoText = false;
cht.ValueAxis.DisplayUnitLabel.Text = "亿";
}
@lingtian
dest (5).zip (22.4 KB)
I tried two solutions, all work fine with the latest version 25.10.
var wb = new Workbook(dir + "book1.xlsx");
wb.Settings.GlobalizationSettings.ChartSettings = new CustomChartSetttings();
Chart chart = wb.Worksheets[0].Charts[0];
//Console.WriteLine(chart.ValueAxis.DisplayUnit);
//Console.WriteLine(chart.ValueAxis.DisplayUnitLabel.Text);
//chart.ValueAxis.DisplayUnitLabel.Text = "亿";
chart.ToImage(dir + "dest.jpg");
class CustomChartSetttings : ChartGlobalizationSettings
{
public override string GetAxisUnitName(DisplayUnitType type)
{
if (type == DisplayUnitType.HundredMillions)
{
return "亿";
}
else
return type.ToString();
}
}
Thank you, but I need the Excel file to also display as “亿”.
Yes, we will look into Excel file rendering with your desired customized unit labels and get back to you soon.
@lingtian
By testing on the latest version v25.10 using sample files and the following sample code, we can reproduce the issue. Excel file cannot set custom unit labels after setting Chart.ValueAxis.DisplayUnitLabel.Text property. Please refer to the attachment. result.zip (34.0 KB)
Workbook wb = new Workbook(filePath + "book1.xlsx");
wb.Settings.GlobalizationSettings.ChartSettings = new CustomChartSetttings();
Chart chart = wb.Worksheets[0].Charts[0];
if (chart.ValueAxis.DisplayUnit == DisplayUnitType.HundredMillions)
{
chart.ValueAxis.DisplayUnitLabel.IsAutoText = false;
chart.ValueAxis.DisplayUnitLabel.Text = "亿";
}
chart.ToImage(filePath + "out_net.jpg");
wb.Save(filePath + "out_net.xlsx");
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-59197
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
We are pleased to inform you that your issue (Ticket ID: “CELLSNET-59197”) has been resolved. The fix will be included in the upcoming release (Aspose.Cells v25.11) that we plan to release in the first half of November 2025. You will be notified when the next version is released.