From 726fa5c85e595d871bc78743a663b04f85bb7860 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 8 Nov 2023 11:14:47 +0000 Subject: [PATCH] temp workaround for chart axis issue git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1913671 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/examples/xslf/ChartFromScratch.java | 4 ++++ .../java/org/apache/poi/examples/xssf/usermodel/BarChart.java | 4 ++++ .../org/apache/poi/examples/xssf/usermodel/LineChart.java | 4 ++++ .../org/apache/poi/examples/xssf/usermodel/ScatterChart.java | 4 ++++ .../apache/poi/examples/xwpf/usermodel/ChartFromScratch.java | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xslf/ChartFromScratch.java b/poi-examples/src/main/java/org/apache/poi/examples/xslf/ChartFromScratch.java index 121b642a0c..83967307a3 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/xslf/ChartFromScratch.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/xslf/ChartFromScratch.java @@ -180,6 +180,10 @@ public final class ChartFromScratch { chart.setTitleText(chartTitle); chart.setTitleOverlay(false); chart.setAutoTitleDeleted(false); + + // temporary workaround for https://bz.apache.org/bugzilla/show_bug.cgi?id=67510 + if (bottomAxis.hasNumberFormat()) bottomAxis.setNumberFormat("@"); + if (leftAxis.hasNumberFormat()) leftAxis.setNumberFormat("#,##0.00"); } private static final int COLUMN_LANGUAGES = 0; diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BarChart.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BarChart.java index 7f1f1c5ec6..76dbf67f19 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BarChart.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BarChart.java @@ -104,6 +104,10 @@ public final class BarChart { solidFillSeries(data, 0, PresetColor.CHARTREUSE); solidFillSeries(data, 1, PresetColor.TURQUOISE); + // temporary workaround for https://bz.apache.org/bugzilla/show_bug.cgi?id=67510 + if (bottomAxis.hasNumberFormat()) bottomAxis.setNumberFormat("@"); + if (leftAxis.hasNumberFormat()) leftAxis.setNumberFormat("#,##0.00"); + // Write the output to a file try (FileOutputStream fileOut = new FileOutputStream("ooxml-bar-chart.xlsx")) { wb.write(fileOut); diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/LineChart.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/LineChart.java index d0cf568e6a..32948c694c 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/LineChart.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/LineChart.java @@ -105,6 +105,10 @@ public final class LineChart { solidLineSeries(data, 0, PresetColor.CHARTREUSE); solidLineSeries(data, 1, PresetColor.TURQUOISE); + // temporary workaround for https://bz.apache.org/bugzilla/show_bug.cgi?id=67510 + if (bottomAxis.hasNumberFormat()) bottomAxis.setNumberFormat("@"); + if (leftAxis.hasNumberFormat()) leftAxis.setNumberFormat("#,##0.00"); + // Write the output to a file try (FileOutputStream fileOut = new FileOutputStream("ooxml-line-chart.xlsx")) { wb.write(fileOut); diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/ScatterChart.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/ScatterChart.java index c74de7f840..47daa07084 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/ScatterChart.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/ScatterChart.java @@ -99,6 +99,10 @@ public final class ScatterChart { solidLineSeries(data, 0, PresetColor.CHARTREUSE); solidLineSeries(data, 1, PresetColor.TURQUOISE); + // temporary workaround for https://bz.apache.org/bugzilla/show_bug.cgi?id=67510 + if (bottomAxis.hasNumberFormat()) bottomAxis.setNumberFormat("@"); + if (leftAxis.hasNumberFormat()) leftAxis.setNumberFormat("#,##0.00"); + // Write the output to a file try (FileOutputStream fileOut = new FileOutputStream("ooxml-scatter-chart.xlsx")) { wb.write(fileOut); diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xwpf/usermodel/ChartFromScratch.java b/poi-examples/src/main/java/org/apache/poi/examples/xwpf/usermodel/ChartFromScratch.java index 0625204699..6a346aa97b 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/xwpf/usermodel/ChartFromScratch.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/xwpf/usermodel/ChartFromScratch.java @@ -146,6 +146,10 @@ public final class ChartFromScratch { chart.setTitleText(chartTitle); chart.setTitleOverlay(false); chart.setAutoTitleDeleted(false); + + // temporary workaround for https://bz.apache.org/bugzilla/show_bug.cgi?id=67510 + if (bottomAxis.hasNumberFormat()) bottomAxis.setNumberFormat("@"); + if (leftAxis.hasNumberFormat()) leftAxis.setNumberFormat("#,##0.00"); } private static final int COLUMN_LANGUAGES = 0;