Files
2026-04-05 20:39:21 +05:00

33 lines
1.2 KiB
Java
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package lr10.task_1;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
public class e8 {
public static void main(String[] args) throws IOException {
// Открываем файл Excel для чтения
String filePath = "example3.xlsx";
FileInputStream inputStream = new FileInputStream(filePath);
// Создаем экземпляр книги Excel из файла
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
// Получаем лист из книги по его имени
XSSFSheet sheet = workbook.getSheet("Товары");
// Перебираем строки и ячейки листа
for (Row row : sheet) {
for (Cell cell : row) {
// Выводим значение ячейки на экран
System.out.print(cell.toString() + "\t");
}
System.out.println();
}
// Закрываем файл и освобождаем ресурсы
workbook.close();
inputStream.close();
}
}