Cách Đọc File Excel Trong Java / Top 4 # Xem Nhiều Nhất & Mới Nhất 3/2023 # Top View | Hoisinhvienqnam.edu.vn

Đọc Ghi File Excel Trong Java Với Jxl

Tạo và ghi file Excel với Jxl

Bước 1: Tạo đối tượng WritableWorkbook “trỏ” đến file của bạn. Lưu ý là nếu file của bạn đã tồn tại thì nó sẽ bị xóa đi và tạo lại.

WritableWorkbook workbook = Workbook.createWorkbook(new File(fileName));

Bước 2: Tạo WritableSheet – sheet bạn cần ghi dữ liệu:

WritableSheet sheet = workbook.createSheet("name sheet", 0);

Lưu ý: trong hàm createSheet có 2 đối số, đối số thứ nhất là chuỗi tên sheet, đối số thứ 2 là một số nguyên chỉ vị trí của sheet, vị trí sheet bắt đầu bằng 0.

Bước 3: Tiếp theo chúng ta sẽ thêm các dạng dữ liệu vào các ô bằng phương thức addCell. Để viết dữ liệu vào các ô, chúng ta sẽ có 3 dạng chính: Chuỗi, Số và Công thức lần lượt được tạo bằng Label, Number, Formula. Ví dụ:

sheet.addCell(new Label(0, 0, "Add a String to cell")); sheet.addCell(new Number(0, 1, 100)); sheet.addCell(new Formula(0, 3, "IF(A1=1,"one", "two")"));

Bước 4: Sau khi chúng ta đã thực hiện xong bước 3, chúng ta cần thực hiện lệnh write và close để hoàn tất việc ghi dữ liệu

workbook.write(); workbook.close();

Đọc file Excel với Jxl

Bước 1: Tạo Workbook “trỏ” đến file của bạn.

Workbook workbook = Workbook.getWorkbook(new File(fileName));

Bước 2: Lấy Sheet bạn muốn đọc. Bạn có thể lấy theo vị trí sheet hoặc tên Sheet

Sheet sheet = workbook.getSheet(0);

Bước 3: Đọc nội dung từng ô trong bảng tính. Nếu bạn muốn lấy nội dung của một ô nào đó bạn có thể làm như sau: sheet.getCell(col, row).getContents(). Tuy nhiên nếu bạn muốn đọc toàn bộ các ô trong bảng tính hãy lấy hàng và cột cuối cùng chứa dữ liệu bằng sheet.getRows() và sheet.getColumns(), và dùng vòng lặp for để đọc từng ô. Sau khi đọc xong, chúng ta cũng cần close workbook như khi viết dữ liệu

for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { Cell cell = sheet.getCell(col, row); System.out.print(cell.getContents() + "t"); } System.out.println("n"); } workbook.close();

Mở và ghi thêm dữ liệu vào Excel với Jxl

Để mở và ghi thêm dữ liệu vào file Excel, trước tiên chúng ta cần lấy Workbook từ file Excel cần viết thêm giống như khi chúng ta đọc. Sau đó tạo một WritableWorkbook đến chính workbook vừa lấy và chúng ta sẽ làm việc với WritableWorkbook này bình thường.

Workbook workbook = Workbook.getWorkbook(new File(fileName)); WritableWorkbook writeWorkbook = Workbook.createWorkbook(new File(fileName), workbook);

Demo code

package vietSource.net.IOFile; import java.io.File; import java.io.IOException; import java.util.Scanner; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; import jxl.write.Formula; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import jxl.write.WriteException; import jxl.write.biff.RowsExceededException; /** */ public class ReadWriteExcel { private final String fileName = "/home/nguyenvanquan7826/Desktop/nguyenvanquan7826.xls"; private Object[][] data = { { "STT", "Họ và tên", "Điểm", "Xếp loại" }, { "1", "Nguyễn Văn Quân", "9.0", "" }, { "2", "Phạm Thị Hà", "8.0", "" }, { "3", "Nguyễn Bá Cường", "8.5", "" }, { "4", "Vũ Công Tịnh", "9.0", "" }, { "5", "Phạm Trọng Khang", "8", "" }, { "6", "Mai Văn Tài", "8", "" } }; private void writeFileExcel() { WritableWorkbook workbook; try { workbook = Workbook.createWorkbook(new File(fileName)); WritableSheet sheet1 = workbook.createSheet("KTPM K10B", 0); sheet1.addCell(new Label(0, 0, "DANH SÁCH SINH VIÊN TIÊU BIỂU")); int rowBegin = 2; int colBegin = 0; for (int row = rowBegin, i = 0; row < data.length + rowBegin; row++, i++) { for (int col = colBegin, j = 0; col < data[0].length + colBegin; col++, j++) { Object obj = data[i][j]; sheet1.addCell(new Label(col, row, (String) data[i][j])); } } workbook.write(); workbook.close(); } catch (IOException e) { System.out.println("Error create file " + e.toString()); } catch (RowsExceededException e) { System.out.println("Error write file " + e.toString()); } catch (WriteException e) { System.out.println("Error write file " + e.toString()); } System.out.println("create and write success"); } private void readFileExcel() { Workbook workbook; try { workbook = Workbook.getWorkbook(new File(fileName)); Sheet sheet = workbook.getSheet(0); int rows = sheet.getRows(); int cols = sheet.getColumns(); System.out.println("Data in file:"); for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { Cell cell = sheet.getCell(col, row); System.out.print(cell.getContents() + " "); } System.out.println(" "); } workbook.close(); } catch (BiffException e) { System.out.println("File not found " + e.toString()); } catch (IOException e) { System.out.println("File not found " + e.toString()); } } private void openAndWriteFileExcel() { Workbook workbook; WritableWorkbook writeWorkbook; try { workbook = Workbook.getWorkbook(new File(fileName)); writeWorkbook = Workbook.createWorkbook(new File(fileName), workbook); WritableSheet sheet1 = writeWorkbook.getSheet(0); int col = 3; int rowBegin = 3; for (int row = rowBegin; row < data.length + rowBegin - 1; row++) { Formula f = new Formula(col, row, "IF(C" + (row + 1) sheet1.addCell(f); } writeWorkbook.write(); writeWorkbook.close(); } catch (IOException e) { System.out.println("File not found " + e.toString()); } catch (RowsExceededException e) { System.out.println("File not found " + e.toString()); } catch (WriteException e) { System.out.println("File not found " + e.toString()); } catch (BiffException e) { System.out.println("File not found " + e.toString()); } System.out.println("open and write success"); } private void showMenu() { System.out.println(); System.out.println("Select an integer for process:"); System.out.println("1 - Create new file and wrire data"); System.out.println("2 - Read file exits"); System.out.println("3 - Open and write to file exits"); } public static void main(String[] args) { ReadWriteExcel rwExcel = new ReadWriteExcel(); while (true) { rwExcel.showMenu(); Scanner scan = new Scanner(System.in); int select = Integer.parseInt(scan.nextLine()); switch (select) { case 1: rwExcel.writeFileExcel(); break; case 2: rwExcel.readFileExcel(); break; case 3: rwExcel.openAndWriteFileExcel(); break; default: scan.close(); break; } } } }

Đọc Ghi File Excel Bằng Java Sử Dụng Apache Poi

Đọc ghi file Excel bằng Java sử dụng Apache POI

Apache POI là một thư viện mã nguồn mở cung cấp bởi apache được sử dụng để xử lý các file office như word, excel, powerpoint…

1.1 Xử lý file Excel với Apache POI

Apache POI xử lý các thành phần trong excel theo đúng lập trình hướng đối tượng – mỗi thành phần trong Excel đều được coi như 1 đối tượng.

Các class cơ bản được dùng để đọc ghi file Excel

HSSF: các class có tên bắt đầu là HSSF được dùng để sử lý các file Microsoft Excel 2003 (.xls)

XSSF: các class có tên bắt đầu là XSSF được dùng để sử lý các file Microsoft Excel 2007 trở về sau (.xlsx)

XSSFWorkbook và HSSFWorkbook là các class xử lý với Excel Workbook

HSSFSheet và XSSFSheet là các class xử lý với Excel Worksheet

Row: định nghĩa một dòng trong excel

Cell: định nghĩa một ô trong excel

Ở đây mình sử dụng maven để lấy thư viện của Apache POI.

Cho các file Microsoft Excel 2003

Cho các file Microsoft Excel 2007 trở về sau

3.1 Ghi file Excel

Tạo 1 Worksheet có name là “Customer_Info”

dòng đầu tiên hiển thị “List Of Customer”

Các dòng tiếp theo hiển thị các thông tin của customer (id, name, email), mỗi thông tin ở 1 column.

package stackjava.com.apachepoiexcel.demo; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class WriteFileExcel { public static void main(String[] args) { System.out.println("Create file excel"); XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet("Customer_Info"); int rowNum = 0; Row firstRow = sheet.createRow(rowNum++); Cell firstCell = firstRow.createCell(0); firstCell.setCellValue("List of Customer"); listOfCustomer.add(new Customer(1, "Sylvester Stallone", "abc@gmail.com")); listOfCustomer.add(new Customer(2, "Tom Cruise", "xyz@yahoo.com")); listOfCustomer.add(new Customer(3, "Vin Diesel", "abc@hotmail.com")); for (Customer customer : listOfCustomer) { Row row = sheet.createRow(rowNum++); Cell cell1 = row.createCell(0); cell1.setCellValue(customer.getId()); Cell cell2 = row.createCell(1); cell2.setCellValue(customer.getName()); Cell cell3 = row.createCell(2); cell3.setCellValue(customer.getEmail()); } try { FileOutputStream outputStream = new FileOutputStream("Demo-ApachePOI-Excel.xlsx"); workbook.write(outputStream); workbook.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println("Done"); } } package stackjava.com.apachepoiexcel.demo; public class Customer { private int id; private String name; private String email; }

Kết quả:

Bây giờ mình sẽ thực hiện đọc lại file Excel vừa tạo ở trên:

package stackjava.com.apachepoiexcel.demo; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class ReadFileExcel { public static void main(String[] args) { try { FileInputStream excelFile = new FileInputStream(new File("Demo-ApachePOI-Excel.xlsx")); Workbook workbook = new XSSFWorkbook(excelFile); Sheet datatypeSheet = workbook.getSheetAt(0); DataFormatter fmt = new DataFormatter(); Row firstRow = iterator.next(); Cell firstCell = firstRow.getCell(0); System.out.println(firstCell.getStringCellValue()); while (iterator.hasNext()) { Row currentRow = iterator.next(); Customer customer = new Customer(); customer.setId(Integer.parseInt(fmt.formatCellValue(currentRow.getCell(0)))); customer.setName(currentRow.getCell(1).getStringCellValue()); customer.setEmail(currentRow.getCell(2).getStringCellValue()); listOfCustomer.add(customer); } for (Customer customer : listOfCustomer) { System.out.println(customer); } workbook.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }

*Lưu ý: id của customer là integer nên khi ghi vào file excel nó sẽ là kiểu numeric, do đó khi đọc ra thì nó sẽ đọc là numeric và chuyển thành double, ví dụ 1 sẽ là 1.0. Do đó ta dùng DataFormatter để định dạng nó về kiểu string và parse lại thành integer.

Kết quả:

List of Customer Customer [id=1, name=Sylvester Stallone, email=abc@gmail.com] Customer [id=2, name=Tom Cruise, email=xyz@yahoo.com] Customer [id=3, name=Vin Diesel, email=abc@hotmail.com]

Okay, Done!

Đọc ghi file Excel bằng Java sử dụng Apache POI

Reference:

Hướng Dẫn Đọc Và Ghi File Excel Trong Java Sử Dụng Thư Viện Apache Poi

Excel là định dạng file rất phổ biến được tạo ra bởi Microsoft. Thông thường, các ứng dụng Java sử dụng thư viện Apache POI để đọc và ghi tập tin Excel. Trong bài này, tôi sẽ hướng dẫn cách để đọc và ghi các tập tin Excel sử dụng API của thư viện Apache POI.

Giới thiệu về Apache POI?

Apache POI là một thư viện mã nguồn mở Java, được cung cấp bởi Apache. Thư viện này cung cấp các API (phương thức) làm việc với các tài liệu của Microsoft như Word, Excel, Power point, Visio,…

Các class của Apache POI thường có tiếp đầu ngữ HSSF, XSSF, HPSF, … Nhìn vào tiếp đầu ngữ của một class bạn có thể biết được class đó hỗ trợ loại định dạng nào.

HSSF (Horrible SpreadSheet Format): Đọc và ghi file định dạng Microsoft Excel (XLS – định dạng hỗ trợ của Excel 2003).

XSSF (XML SpreadSheet Format): Đọc và ghi định dạng file Open Office XML (XLSX – định dạng hỗ trợ của Excel 2007 trở lên).

SXSSF (Streaming version of XSSFWorkbook) : SXSSF là một phần mở rộng API của XSSF, được sử dụng khi xuất các file excel lớn và có bộ nhớ heap sapce hạn chế.

Tổng quan Apache POI Excel

Microsoft Excel hiện tại có 2 phần mở rộng:

.xls: tương ứng với phiên bản Microsoft Excel 2003 trở về trước. Định dạng này được Apache POI hỗ trợ bởi các lớp java với tiếp đầu ngữ là HSSF.

.xlsx: tương ứng với phiên bản Microsoft Excel 2007 trở về sau. Định dạng này được Apache POI hỗ trợ bởi các lớp java với tiếp đầu ngữ là XSSF, SXSSF.

Một số khái niệm cơ bản của Apache API:

Apache POI cung cấp cho bạn các interface Workbook, Sheet, Row, Cell,… và các class thể hiện (implementation) tương ứng:

Workbook: đại diện cho một file Excel. Nó được triển khai dưới hai class là: HSSFWorkbook và XSSFWorkbook tương ứng cho định dạng .xls và .xlsx .

Sheet: đại diện cho một bảng tính Excel (một file Excel có thể có nhiều Sheet). Nó có 2 class là HSSFSheet và XSSFSheet.

Row: đại diện cho một hàng trong một bảng tính (Sheet). Nó có 2 class là HSSFRow và XSSFRow.

Cell: đại diện cho một ô trong một hàng (Row). Tương tự nó cũng có 2 class là HSSFCell and XSSFCell.

Khai báo thư viện Apache POI

Tạo Maven project và khai báo thư viện trong file chúng tôi của project như sau:

Lưu ý: Các phiên bản cũ của Apache POI chỉ hỗ trợ các định dạng file binary như doc, xls, ppt, … .Từ phiên bản 3.5 trở đi, POI hỗ trợ các định dạng file OOXML của MS-Office như docx, xlsx, pptx, …

Ví dụ đọc và ghi file Excel

Microsoft Office các phiên bản trước đây (97-2003) các file excel có định dạng .xls và các phiên bản mới hơn (2007 trở về sau) thường sử dụng định dạng .xlsx. Để thao tác với các file .xls cần sử dụng các class có tiếp đầu ngữ HSSF. Còn đối với các file định dạng .xlsx cần sử dụng các class có tiếp đầu ngữ XSSF.

Ví dụ ghi file excel (.xls, .xlsx)

Book.java

package com.gpcoder.apachepoi; public class Book { private Integer id; private String title; private Integer quantity; private Double price; private Double totalMoney; }

WriteExcelExample.java

Thực thi chương trình trên, một file chúng tôi được tạo ra trong thư mục C:/demo như sau:

Ví dụ đọc file excel (.xls, .xlsx)

Kết quả thực thi chương trình trên:

Book [id=1, title=Book 1, quantity=2, price=1000.0, totalMoney=2000.0] Book [id=2, title=Book 2, quantity=4, price=2000.0, totalMoney=8000.0] Book [id=3, title=Book 3, quantity=6, price=3000.0, totalMoney=18000.0] Book [id=4, title=Book 4, quantity=8, price=4000.0, totalMoney=32000.0] Book [id=5, title=Book 5, quantity=10, price=5000.0, totalMoney=50000.0] Book [id=null, title=null, quantity=null, price=null, totalMoney=110000.0]

Lưu ý:

Các kiểu dữ liệu số khi đọc từ file excel sẽ có giá trị là kiểu double.

Nguồn: https://gpcoder.com/3144-huong-dan-doc-va-ghi-file-excel-trong-java-su-dung-thu-vien-apache-poi/

All Rights Reserved

Java: Cách Tạo Và Chèn Dữ Liệu Vào File Excel

Trong Java, việc đọc tệp excel và ghi tệp excel có một chút khó khăn vì trang tính Excel có các ô để lưu trữ dữ liệu. Java không cung cấp API trực tiếp để đọc hoặc viết các tài liệu Microsoft Excel hoặc Word. Ta sẽ phải dựa vào thư viện của bên thứ ba là Apache POI. Trong phần này, chúng ta sẽ học cách tạo một tệp excel bằng Java và cách ghi hoặc chèn dữ liệu vào tệp excel bằng thư viện Apache POI Java.

1. Thư viện POI Java Apache

Apache POI (Thực hiện giải mã kém) là một API Java để đọc và ghi Tài liệu Microsoft. Nó chứa các lớp và giao diện. Thư viện Apache POI cung cấp hai cách triển khai để đọc hoặc ghi tệp excel:

Triển khai HSSF (Horrible SpreadSheet Format): Nó biểu thị một API đang hoạt động với Excel 2003 hoặc các phiên bản cũ hơn.

Triển khai XSSF (XML SpreadSheet Format): Nó biểu thị một API đang hoạt động với phiên bản Excel 2007 trở lên.

Trong phần này sẽ sẽ sử dụng triển khai HSSF.

2. Tạo file Excel trong Java

Bước 1: Tạo một dự án Java với tên CreateExcelFile từ IntelliJ.

Bước 2: Tạo một lớp tên CreateExcelFileExample1.

Bước 2: Tải xuống thư viện Apache POI ( poi-3.17.jar).

Bước 5: Nhấp chọn Libraries sau đó nhấn dấu + và chọn Java như hình dưới:

Bước 6: Tìm đến nơi chứa file chúng tôi rồi chọn và nhấp vào nút OK. Điều này sẽ thêm tệp JAR vào dự án. Sau đó, nhấp vào nút Apply để áp dụng các thay đổi rồi nhấn nút OK.

Sau khi đã hoàn thành tất cả các bước trên, cấu trúc dự án sẽ giống như sau:

Giờ ta sẽ tiếp tục với các đoạn mã:

Trong chương trình sau, ta sử dụng thư viện Apache POI để tạo một file excel. Thư viện cung cấp lớp có tên HSSFWorkbook được định nghĩa trong gói org.apache.poi.hssf.usermodel.

CreateExcelFileExample1.java ​

import java.io.*; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Workbook; public class CreateExcelFileExample1 { public static void main(String[] args) throws IOException {

Kết quả:

“C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.3.1jbrbinjava.exe” “-javaagent:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.3.1libidea_rt.jar=58544:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.3.1bin” -Dfile.encoding=UTF-8 -classpath E:CoursesJavaCreateExcelFileoutproductionCreateExcelFile;E:CoursesJavaCreateExcelFilepoi-3.17.jar CreateExcelFileExample1 File Excel đã được tạo thành công.

Ta đã tạo được một file excel trống tại vị trí được chỉ định.

Giờ ta tạo một chương trình Java khác để tạo một tệp excel.

CreateExcelFileExample2.java​

import java.io.*; public class CreateExcelFileExample2 { public static void main(String[] args) { try { String filename = "C: \ Users \ Anubhav \ Desktop \ CustomersDetail.xlsx"; FileOutputStream fileOut = new FileOutputStream(filename); fileOut.close(); System.out.println("File Excel được tạo thành công."); } catch (Exception e) { e.printStackTrace(); } } }

Kết quả:

“C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.3.1jbrbinjava.exe” “-javaagent:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.3.1libidea_rt.jar=58581:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.3.1bin” -Dfile.encoding=UTF-8 -classpath E:CoursesJavaCreateExcelFileoutproductionCreateExcelFile;E:CoursesJavaCreateExcelFilepoi-3.17.jar CreateExcelFileExample2 File Excel được tạo thành công.

Ta đã tạo được một tệp excel trống tại vị trí được chỉ định.

3. Tạo và chèn dữ liệu vào file Excel

CreateExcelFileExample3.java

import java.io.*; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFRow; public class CreateExcelFileExample3 { public static void main(String[] args) { try { ""//khai báo tên file muốn tạo String filename = "E: \ Courses \ Java \ CreateExcelFile \ Excel3.xlsx";//tạo một đối tượng của lớp HSSFWorkbook HSSFWorkbook workbook = new HSSFWorkbook();//gọi phương thức creatSheet() và truyền tên file muốn tạo HSSFSheet sheet = workbook.createSheet("January");//tạo hàng thứ 0 sử dụng phương thức createRow() HSSFRow rowhead = sheet.createRow((short) 0);//tạo ô bằng cách sử dụng phương thức createCell() và thiết lập giá trị cho ô bằng cách sử dụng phương thức setCellValue() rowhead.createCell(0).setCellValue("S.No."); rowhead.createCell(1).setCellValue("Customer Name"); rowhead.createCell(2).setCellValue("Account Number"); rowhead.createCell(3).setCellValue("e-mail"); rowhead.createCell(4).setCellValue("Balance");//tạo hàng thứ 1 HSSFRow row = sheet.createRow((short) 1);//chèn dữ liệu vào hàng thứ 1 row.createCell(0).setCellValue("1"); row.createCell(1).setCellValue("John William"); row.createCell(2).setCellValue("9999999"); row.createCell(3).setCellValue(row.createCell(4).setCellValue("700000.00");//tạo hàng thứ 2 HSSFRow row1 = sheet.createRow((short) 2);//chèn dữ liệu vào hàng thứ 2 row1.createCell(0).setCellValue("2"); row1.createCell(1).setCellValue("Mathew Parker"); row1.createCell(2).setCellValue("22222222"); row1.createCell(3).setCellValue(row1.createCell(4).setCellValue("200000.00"); FileOutputStream fileOut = new FileOutputStream(filename); workbook.write(fileOut);//đóng stream fileOut.close();//đóng workbook workbook.close();//in thông báo tạo thành công System.out.println("File Excel đã được tạo thành công."); } catch (Exception e) { e.printStackTrace(); } } }[email protected]");[email protected]");

Kết quả:

“C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.3.1jbrbinjava.exe” “-javaagent:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.3.1libidea_rt.jar=58597:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.3.1bin” -Dfile.encoding=UTF-8 -classpath E:CoursesJavaCreateExcelFileoutproductionCreateExcelFile;E:CoursesJavaCreateExcelFilepoi-3.17.jar CreateExcelFileExample3 File Excel đã được tạo thành công.

Nó tạo một tệp excel tại vị trí được chỉ định với các giá trị mà ta đã chèn bằng cách sử dụng phương thức setCellValue().