-1
I need to upload a file . xlsx that is in a directory to my tool.
What API or implementation can I use to upload?
-1
I need to upload a file . xlsx that is in a directory to my tool.
What API or implementation can I use to upload?
1
You can use the public Apache POI for that reason
Below is an example of how you can upload a file. xlsx with Apache POI library, later you can save it in a directory you find more convenient.
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
public class ExcelReader {
public static final String XLSX_FILE_PATH = "./arquivo-excel.xlsx";
public static void main(String[] args) throws IOException, InvalidFormatException {
//Criando um Workbook de Uma Arquivo Excel (.xlsx ou .xls)
Workbook workbook = WorkbookFactory.create(new File(XLSX_FILE_PATH));
//Visualizando Todas as Sheets presentes na planilha
for(Sheet sheet: workbook) {
System.out.println("=> " + sheet.getSheetName());
}
// Visualizando os valores das células da primeira aba da planilha
Sheet sheet = workbook.getSheetAt(0);
for (Row row: sheet) {
for(Cell cell: row) {
String cellValue = dataFormatter.formatCellValue(cell);
System.out.print(cellValue + "\t");
}
System.out.println();
}
workbook.close();
}
}
Workbook: A workbook is the high-level representation of a worksheet.
Sheet: Represents a worksheet tab. A workbook can contain many tabs.
Row: As the name suggests, represents a line in the spreadsheet.
Cell: a cell represents an element in the worksheet column.
Browser other questions tagged java eclipse
You are not signed in. Login or sign up in order to post.
Thanks for the alternative, I used and it worked
– Ricarte