aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-07-20 12:43:52 +0000
committerPJ Fanning <fanningpj@apache.org>2021-07-20 12:43:52 +0000
commit0678b16f141980cb846c7e0e2c38cdcb25573867 (patch)
tree4bfe53566cd6e081553e296caa387990f290f34d
parenta18e04b3693dbc9e3aff40b653f4dc982a95919a (diff)
downloadpoi-0678b16f141980cb846c7e0e2c38cdcb25573867.tar.gz
poi-0678b16f141980cb846c7e0e2c38cdcb25573867.zip
right to left xlsx test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891682 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java47
-rw-r--r--test-data/spreadsheet/right-to-left.xlsxbin0 -> 14478 bytes
2 files changed, 33 insertions, 14 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
index ef17baa8e7..58beb8896b 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
@@ -31,11 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.Iterator;
@@ -58,16 +54,10 @@ import org.apache.poi.openxml4j.opc.internal.FileHelper;
import org.apache.poi.openxml4j.opc.internal.MemoryPackagePart;
import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart;
import org.apache.poi.ss.tests.usermodel.BaseTestXWorkbook;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.RichTextString;
-import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.AreaReference;
+import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LocaleUtil;
@@ -83,7 +73,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
-public final class TestXSSFWorkbook extends BaseTestXWorkbook {
+public final class TestXSSFWorkbook extends BaseTestXWorkbook {
public TestXSSFWorkbook() {
super(XSSFITestDataProvider.instance);
@@ -1136,4 +1126,33 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
wbBack.close();
wbBack2.close();
}
+
+ @Test
+ void testRightToLeft() throws IOException {
+ try(XSSFWorkbook workbook = openSampleWorkbook("right-to-left.xlsx")){
+ Sheet sheet = workbook.getSheet("عربى");
+
+ Cell A1 = sheet.getRow(0).getCell(0);
+ Cell A2 = sheet.getRow(1).getCell(0);
+ Cell A3 = sheet.getRow(2).getCell(0);
+ Cell A4 = sheet.getRow(3).getCell(0);
+
+ expectFormattedContent(A1, "نص");
+ expectFormattedContent(A2, "123"); //this should really be ۱۲۳
+ expectFormattedContent(A3, "text with comment");
+ expectFormattedContent(A4, " עִבְרִית and اَلْعَرَبِيَّةُ");
+
+ Comment a3Comment = sheet.getCellComment(new CellAddress("A3"));
+ assertTrue(a3Comment.getString().getString().contains("تعليق الاختبا"));
+ }
+ }
+
+ private static void expectFormattedContent(Cell cell, String value) {
+ assertEquals(value, new DataFormatter().formatCellValue(cell),
+ "Cell " + ref(cell) + " has wrong formatted content.");
+ }
+
+ private static String ref(Cell cell) {
+ return new CellReference(cell).formatAsString();
+ }
}
diff --git a/test-data/spreadsheet/right-to-left.xlsx b/test-data/spreadsheet/right-to-left.xlsx
new file mode 100644
index 0000000000..48e3353723
--- /dev/null
+++ b/test-data/spreadsheet/right-to-left.xlsx
Binary files differ