Hi,
When using Chart.ToImage and CultureInfo is set the date format in the generated image is not conforming to the date format of the CultureInfo.
To reproduce the issue use the attached XLSX file and the following code.
Please compare the date format between the image of the chart and the image of the range used as data for the chart for different CultureInfos generated by the code (I’m attaching for reference images for CultureInfo=“ja-JP”):
var workbook = new Workbook(“Chart.xlsx”);
var cultureInfos = new[] {“sv-SE”, “fr-FR”, “ja-JP”, “ru-RU”, “es-ES”};
var imageOptions = new ImageOrPrintOptions
{
Quality = 100,
VerticalResolution = 200,
HorizontalResolution = 200,
PrintingPage = PrintingPageType.IgnoreBlank,
ImageFormat = ImageFormat.Png,
OnePagePerSheet = true,
OnlyArea = true
};
foreach (var cultureInfo in cultureInfos)
{
workbook.Settings.CultureInfo = new CultureInfo(cultureInfo);
var chart = workbook.Worksheets[0].Charts[0];
var chartImage = chart.ToImage(imageOptions);
chartImage.Save(cultureInfo + “-chart.bmp”);
workbook.Worksheets[0].PageSetup.PrintArea = “C24:D26”;
var sheetRender = new SheetRender(workbook.Worksheets[0], imageOptions);
sheetRender.ToImage(0, cultureInfo + “-range.bmp”);
}
Hi Sorin,
Hi Babar,
This is not exactly the issue, the problem is the date format in the chart is not respecting the date format corresponding to the CultureInfo.
For example: the date format specified by Japanese CultureInfo (“ja-JP”) is yyyy/mm/dd (see the attached screenshot of Visual Studio debug screenshot); in the attached image you can see the cells are displaying the correct date format for the Japanese CultureInfo but the chart is not respecting that format (I used red ellipses to show the difference).
The chart should display: “2013/12/10”, “2014/09/26” and “2013/12/11”.
Thank you,
Aurelian Iordache
IBM Romania
Hi Aurelian,
Hi Babar,
Thank you very much.
I’d just like to add a quick note - the few cultures I used in the previous code to are just the ones we tested, the issue may be affecting other cultures too, it must be investigated deeper.
Best regards,
Aurelian Iordache
IBM Romania
Hi Aurelian,
Hi,
“Calibri”,“sans-serif”;mso-fareast-font-family:Calibri;mso-fareast-theme-font:
minor-latin;mso-ansi-language:EN-US;mso-fareast-language:EN-SG;mso-bidi-language:
AR-SA”>CELLSNET-43046” now.
The issues you have found earlier (filed as CELLSNET-43046) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.