Incorrect locale in chart text elements

I used Aspose.Cells to create a workbook that contains a chart. My Windows system locale is set to Japan (ja-JP).

The chart was generated using the following code:

var wb = new Workbook();
Worksheet sheet = wb.Worksheets[0];

sheet.Cells["A2"].PutValue("カテゴリー1");
sheet.Cells["A3"].PutValue("カテゴリー2");
sheet.Cells["A4"].PutValue("カテゴリー3");
sheet.Cells["B1"].PutValue("列 1");
sheet.Cells["B2"].PutValue(4);
sheet.Cells["B3"].PutValue(20);
sheet.Cells["B4"].PutValue(50);
sheet.Cells["C1"].PutValue("列 2");
sheet.Cells["C2"].PutValue(50);
sheet.Cells["C3"].PutValue(100);
sheet.Cells["C4"].PutValue(150);

int chartIndex = sheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);
Aspose.Cells.Charts.Chart chart = sheet.Charts[chartIndex];

chart.Title.Text = "マーケット";
chart.SetChartDataRange("A1:C4", true);

wb.Save("Demo3.xlsx");

However, Excel (Japanese) is rendering the chart title using English font. Cells are rendered correctly in Japanese fonts. Upon inspecting the XML (chart1.xml) in the XLSX, it appears that the language of the title is set to “en-US” instead of “ja-JP”.

What setting should I change so text elements in the charts can match the locale of the thread/machine?

<c:chart>
<c:title>
<c:tx>
<c:rich>
<a:bodyPr wrap=“square” />
<a:lstStyle />
<a:p>
<a:pPr algn=“ctr”>
<a:defRPr />
</a:pPr>
<a:r>
<a:rPr lang=“en-US” />
<a:t>マーケット</a:t>
</a:r>
</a:p>
</c:rich>
</c:tx>

Thanks!

@bingxie,

Could you try setting GlobalizationSettings for labels of the chart, see the document for your reference.

If you still could not make it work, kindly share your output file “Demo3.xlsx” created using your code segment. We will look into it soon.

@Amjad_Sahi I can’t figure out how to change the GlobalizationSettings for the Chart Title. The document you linked seems to be only relevant to the Other label in a Pie chart.

I have attached the file to this post. Thanks!

Demo3.zip (8.7 KB)

@bingxie,

Thanks for the output Excel file.

I have logged a ticket with an id “CELLSNET-51924” for your issue. We need to investigate your issue in details. We will look into it soon.

Once we figure it out or we have some other updates on it, we will let you know.

@bingxie
We have supported this feature. With the next version 22.9, you can try the following codes:
var wb = new Workbook();
//Solution 1
// wb.Settings.Region = CountryCode.Japan;
Worksheet sheet = wb.Worksheets[0];

        sheet.Cells["A2"].PutValue("カテゴリー1");
        sheet.Cells["A3"].PutValue("カテゴリー2");
        sheet.Cells["A4"].PutValue("カテゴリー3");
        sheet.Cells["B1"].PutValue("列 1");
        sheet.Cells["B2"].PutValue(4);
        sheet.Cells["B3"].PutValue(20);
        sheet.Cells["B4"].PutValue(50);
        sheet.Cells["C1"].PutValue("列 2");
        sheet.Cells["C2"].PutValue(50);
        sheet.Cells["C3"].PutValue(100);
        sheet.Cells["C4"].PutValue(150);

        int chartIndex = sheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);
        Aspose.Cells.Charts.Chart chart = sheet.Charts[chartIndex];

        chart.Title.Text = "マーケット";
        Aspose.Cells.Drawing.Texts.TextOptions textOptions = chart.Title.TextOptions;

//Solution 2
textOptions.LanguageCode = CountryCode.Japan;
chart.SetChartDataRange(“A1:C4”, true);
wb.Save(dir + “dest.xlsx”);

Thank you @simon.zhao

@bingxie,

You are welcome.

The issues you have found earlier (filed as CELLSNET-51924) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi