import org.adams.framework.ExcelReader; public class ExcelDataReadExample { public static void main(String[] args) { String filePath = "path/to/excel/file.xlsx"; String sheetName = "Sheet1"; ExcelReader excelReader = new ExcelReader(filePath); excelReader.selectSheet(sheetName); int rowCount = excelReader.getRowCount(); int colCount = excelReader.getColumnCount(); for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount; j++) { String cellValue = excelReader.getCellData(i, j); System.out.print(cellValue + "\t"); } System.out.println(); } excelReader.close(); } } import org.adams.framework.ExcelWriter; public class ExcelDataWriteExample { public static void main(String[] args) { String filePath = "path/to/excel/file.xlsx"; String sheetName = "Sheet1"; ExcelWriter excelWriter = new ExcelWriter(filePath); excelWriter.selectSheet(sheetName); int rowCount = 5; int colCount = 3; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount; j++) { String cellValue = "Data " + (i + 1) + "-" + (j + 1); excelWriter.setCellData(i, j, cellValue); } } excelWriter.save(); excelWriter.close(); } }


上一篇:
下一篇:
切换中文