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


##########
website/docs/cli/cli.md:
##########
@@ -0,0 +1,448 @@
+---
+id: 'cli'
+title: 'CLI Tool'
+sidebar_label: 'CLI Tool'
+---
+
+# Fesod CLI
+
+Apache Fesod CLI is a command-line tool for processing Excel spreadsheets. It 
allows you to read, write, convert, and inspect spreadsheet files directly from 
the terminal.
+
+## Features
+
+- **Read**: Extract data from Excel files and output in JSON or CSV format
+- **Write**: Create Excel files from JSON data
+- **Convert**: Convert between different spreadsheet formats (XLS ↔ XLSX) with 
support for multiple sheets
+- **Info**: Display detailed information about spreadsheet files
+
+## Installation
+
+### Download
+
+Download the latest release from the [Fesod 
Releases](https://github.com/apache/fesod/releases) page.
+
+```bash
+# Extract the distribution
+tar -xzf apache-fesod-2.0.0-bin.tar.gz
+cd apache-fesod-2.0.0-bin
+```
+
+### Directory Structure
+
+```text
+apache-fesod-2.0.0-bin/
+├── bin/                    # Executable scripts
+│   ├── fesod-cli           # Unix/Linux/macOS launcher
+│   └── fesod-cli.bat       # Windows launcher
+├── lib/                    # Fesod modules
+├── lib/ext/                # Third-party dependencies
+├── conf/                   # Configuration files
+└── licenses/               # License files
+```
+
+### Requirements
+
+- **Java 8** or higher
+- Supported operating systems: Linux, macOS, Windows
+
+### Verify Installation
+
+```bash
+# Unix/Linux/macOS
+./bin/fesod-cli --version
+
+# Windows
+bin\fesod-cli.bat --version
+```
+
+## Quick Start
+
+### Read Excel File
+
+```bash
+# Output as JSON (default)
+fesod-cli read data.xlsx
+
+# Output as CSV
+fesod-cli read data.xlsx --format csv
+
+# Read specific sheet
+fesod-cli read data.xlsx --sheet "Sales Data"
+
+# Save output to file
+fesod-cli read data.xlsx --output result.json
+```
+
+### Convert File Format
+
+```bash
+# Convert XLS to XLSX (all sheets)
+fesod-cli convert legacy.xls modern.xlsx
+
+# Convert XLSX to XLS (all sheets)
+fesod-cli convert data.xlsx data.xls
+
+# Convert specific sheet only
+fesod-cli convert data.xlsx output.xlsx --sheet 0
+```
+
+### Display File Information
+
+```bash
+fesod-cli info data.xlsx
+```
+
+Example output:
+
+```json

Review Comment:
   The examples in the document are different from the actual output results.
   
   Sample of actual output result:
   ```json
   {
        "file":"../../cli/test_info_01.xlsx",
        "fileSize":13079,
        "sheetCount":4,
        "sheets":[
                {
                        "index":0,
                        "name":"Sheet1",
                        "hidden":false
                },
                {
                        "index":1,
                        "name":"Sheet2",
                        "hidden":false
                },
                {
                        "index":2,
                        "name":"Sheet3",
                        "hidden":true
                },
                {
                        "index":3,
                        "name":"Sheet4",
                        "hidden":false
                }
        ]
   }
   ```



##########
fesod-cli/src/main/java/org/apache/fesod/cli/core/sheet/SheetProcessor.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fesod.cli.core.sheet;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.fesod.cli.core.DocumentProcessor;
+import org.apache.fesod.cli.exception.FileProcessException;
+import org.apache.fesod.sheet.ExcelReader;
+import org.apache.fesod.sheet.FesodSheet;
+import org.apache.fesod.sheet.read.metadata.ReadSheet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Sheet document processor implementation
+ */
+public class SheetProcessor implements DocumentProcessor {
+
+    private static final Logger log = 
LoggerFactory.getLogger(SheetProcessor.class);
+
+    private final SheetReader reader;
+    private final SheetWriter writer;
+    private final SheetConverter converter;
+
+    public SheetProcessor() {
+        this.reader = new SheetReader();
+        this.writer = new SheetWriter();
+        this.converter = new SheetConverter();
+    }
+
+    @Override
+    public Map<String, Object> read(Path inputPath, Map<String, Object> 
options) {
+        log.info("Reading spreadsheet from: {}", inputPath);
+
+        try {
+            Integer sheetIndex = (Integer) options.get("sheetIndex");
+            String sheetName = (String) options.get("sheetName");
+            Boolean readAll = (Boolean) options.get("readAll");
+            if (readAll == null) {
+                readAll = false;
+            }
+
+            return reader.read(inputPath, sheetIndex, sheetName, readAll);
+
+        } catch (Exception e) {
+            throw new FileProcessException("Failed to read spreadsheet:  " + 
e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void write(Map<String, Object> data, Path outputPath, Map<String, 
Object> options) {
+        log.info("Writing spreadsheet to: {}", outputPath);
+
+        try {
+            String sheetName = (String) options.get("sheetName");
+            if (sheetName == null) {
+                sheetName = "Sheet1";
+            }
+            writer.write(data, outputPath, sheetName, options);
+
+        } catch (Exception e) {
+            throw new FileProcessException("Failed to write spreadsheet: " + 
e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void convert(Path inputPath, Path outputPath, Map<String, Object> 
options) {
+        log.info("Converting {} to {}", inputPath, outputPath);
+
+        try {
+            converter.convert(inputPath, outputPath, options);
+
+        } catch (Exception e) {
+            throw new FileProcessException("Failed to convert spreadsheet: " + 
e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public Map<String, Object> getInfo(Path inputPath) {
+        log.info("Getting info for: {}", inputPath);

Review Comment:
   Suggested absolute path for the log output file.
   
   Test Case:
   
   - input
   
   ```bash
   ./fesod-cli info ../../cli/test_info_01.xlsx
   ```
   
   - output:
   
   ```json
   {
        "file":"../../cli/test_info_01.xlsx",
        ...
   }
   ```



##########
fesod-cli/src/main/java/org/apache/fesod/cli/core/sheet/SheetProcessor.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fesod.cli.core.sheet;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.fesod.cli.core.DocumentProcessor;
+import org.apache.fesod.cli.exception.FileProcessException;
+import org.apache.fesod.sheet.ExcelReader;
+import org.apache.fesod.sheet.FesodSheet;
+import org.apache.fesod.sheet.read.metadata.ReadSheet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Sheet document processor implementation
+ */
+public class SheetProcessor implements DocumentProcessor {
+
+    private static final Logger log = 
LoggerFactory.getLogger(SheetProcessor.class);
+
+    private final SheetReader reader;
+    private final SheetWriter writer;
+    private final SheetConverter converter;
+
+    public SheetProcessor() {
+        this.reader = new SheetReader();
+        this.writer = new SheetWriter();
+        this.converter = new SheetConverter();
+    }
+
+    @Override
+    public Map<String, Object> read(Path inputPath, Map<String, Object> 
options) {
+        log.info("Reading spreadsheet from: {}", inputPath);
+
+        try {
+            Integer sheetIndex = (Integer) options.get("sheetIndex");
+            String sheetName = (String) options.get("sheetName");
+            Boolean readAll = (Boolean) options.get("readAll");
+            if (readAll == null) {
+                readAll = false;
+            }
+
+            return reader.read(inputPath, sheetIndex, sheetName, readAll);
+
+        } catch (Exception e) {
+            throw new FileProcessException("Failed to read spreadsheet:  " + 
e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void write(Map<String, Object> data, Path outputPath, Map<String, 
Object> options) {
+        log.info("Writing spreadsheet to: {}", outputPath);
+
+        try {
+            String sheetName = (String) options.get("sheetName");
+            if (sheetName == null) {
+                sheetName = "Sheet1";
+            }
+            writer.write(data, outputPath, sheetName, options);
+
+        } catch (Exception e) {
+            throw new FileProcessException("Failed to write spreadsheet: " + 
e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void convert(Path inputPath, Path outputPath, Map<String, Object> 
options) {
+        log.info("Converting {} to {}", inputPath, outputPath);
+
+        try {
+            converter.convert(inputPath, outputPath, options);
+
+        } catch (Exception e) {
+            throw new FileProcessException("Failed to convert spreadsheet: " + 
e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public Map<String, Object> getInfo(Path inputPath) {
+        log.info("Getting info for: {}", inputPath);
+
+        try {
+            Map<String, Object> info = new LinkedHashMap<String, Object>();
+            List<ReadSheet> sheets;
+
+            try (ExcelReader excelReader = 
FesodSheet.read(inputPath.toFile()).build()) {
+                sheets = excelReader.excelExecutor().sheetList();
+            }
+
+            info.put("file", inputPath.toString());
+            info.put("fileSize", inputPath.toFile().length());
+            info.put("sheetCount", sheets.size());
+
+            List<Map<String, Object>> sheetInfoList = new 
ArrayList<Map<String, Object>>();
+            for (ReadSheet sheet : sheets) {
+                Map<String, Object> sheetInfo = new LinkedHashMap<String, 
Object>();
+                sheetInfo.put("index", sheet.getSheetNo());
+                sheetInfo.put("name", sheet.getSheetName());
+                sheetInfo.put("hidden", sheet.isHidden());
+                sheetInfo.put("rowCount", sheet.getNumRows());

Review Comment:
   The "numRows" property in the ReadSheet class does not represent the number 
of rows of data. This logic is unable to read the number of data rows.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to