You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fesod.apache.org by "delei (via GitHub)" <gi...@apache.org> on 2026/07/12 11:15:51 UTC

Re: [PR] feat: add support for column index limit in ReadSheet [fesod]

delei commented on code in PR #942:
URL: https://github.com/apache/fesod/pull/942#discussion_r3566174788


##########
fesod-sheet/src/test/java/org/apache/fesod/sheet/FesodSheetTest.java:
##########
@@ -247,4 +252,40 @@ void testReadSheet_withAllParams_shouldReturnBuilder() {
         ExcelReaderSheetBuilder builder = FesodSheet.readSheet(0, "DataSheet", 100);
         Assertions.assertNotNull(builder);
     }
+
+    @Test
+    void testReadSheet_withColumnIndexes_shouldConfigureAll() {
+
+        java.util.List<java.util.List<String>> head = new java.util.ArrayList<>();
+        head.add(new ArrayList<>(Arrays.asList("ID")));
+        head.add(new ArrayList<>(Arrays.asList("Name")));
+        head.add(new ArrayList<>(Arrays.asList("Age")));
+        head.add(new ArrayList<>(Arrays.asList("Gender")));
+
+        List<List<Object>> dataList = new ArrayList<>();
+        dataList.add(Arrays.asList("1", "Alice", "30", "Female"));
+
+        FesodSheet.write(tempFile).head(head).sheet("Sheet1").doWrite(dataList);
+
+        List<Integer> targetColumns = Arrays.asList(0, 2);
+
+        ExcelReaderSheetBuilder builder = FesodSheet.readSheetWithColumns(0, "Sheet1", 100, targetColumns);
+        ReadSheet configuredSheet = builder.build();
+        List<Map<Integer, String>> readResults =
+                FesodSheet.read(tempFile).sheet(configuredSheet).doReadSync();
+
+        // builder tests
+        Assertions.assertNotNull(builder, "Builder should not be null");
+        Assertions.assertNotNull(configuredSheet, "The internal ReadSheet should be created");
+        Assertions.assertEquals(1, configuredSheet.getSheetNo());
+        Assertions.assertEquals("Sheet1", configuredSheet.getSheetName());
+        Assertions.assertEquals(100, configuredSheet.getNumRows());
+        Assertions.assertEquals(targetColumns, configuredSheet.getIncludeColumnIndexes());
+        // data related tests
+        Assertions.assertNotNull(readResults);
+        Map<Integer, String> parsedRow = readResults.get(0);
+        Assertions.assertEquals("1", parsedRow.get(0));
+        Assertions.assertEquals("Alice", parsedRow.get(1));

Review Comment:
   Can we continue to develop it so that it can support xls files at the same time?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org