Skip to content

Commit 3030fcc

Browse files
author
Olivier Chédru
authored
Merge pull request #165 from mbrocchieri/caseInsensitiveInZip
allow to be case insensitive inside zip
2 parents ee2b8cd + 01442d4 commit 3030fcc

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

fastexcel-reader/src/main/java/org/dhatim/fastexcel/reader/OPCPackage.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.io.InputStream;
1212
import java.util.ArrayList;
1313
import java.util.Collections;
14+
import java.util.Enumeration;
1415
import java.util.HashMap;
1516
import java.util.List;
1617
import java.util.Map;
@@ -162,6 +163,14 @@ private InputStream getEntryContent(String name) throws IOException {
162163
}
163164
ZipArchiveEntry entry = zip.getEntry(name);
164165
if (entry == null) {
166+
// to be case insensitive
167+
Enumeration<ZipArchiveEntry> entries = zip.getEntries();
168+
while (entries.hasMoreElements()) {
169+
ZipArchiveEntry e = entries.nextElement();
170+
if (e.getName().equalsIgnoreCase(name)) {
171+
return zip.getInputStream(e);
172+
}
173+
}
165174
return null;
166175
}
167176
return zip.getInputStream(entry);

fastexcel-reader/src/test/java/org/dhatim/fastexcel/reader/SimpleReaderTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,21 @@ public void testDefaultWorkbookPath2() throws IOException {
134134
}
135135
}
136136
}
137+
138+
@Test
139+
public void testCaseInsensitiveInFileNames() throws IOException {
140+
try (InputStream is = Resources.open("/xlsx/caseInsensitive.xlsx");
141+
ReadableWorkbook wb = new ReadableWorkbook(is, new ReadingOptions(false, true))) {
142+
Sheet sheet = wb.getFirstSheet();
143+
try (Stream<Row> rows = sheet.openStream()) {
144+
Iterator<Row> it = rows.iterator();
145+
assertTrue(it.hasNext());
146+
Iterator<Cell> cellIt = it.next().iterator();
147+
assertTrue(cellIt.hasNext());
148+
Cell cell = cellIt.next();
149+
assertEquals(CellType.STRING, cell.getType());
150+
assertEquals("A", cell.getValue());
151+
}
152+
}
153+
}
137154
}
5.69 KB
Binary file not shown.

0 commit comments

Comments
 (0)